aboutsummaryrefslogtreecommitdiff
path: root/src/feature/control
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2020-03-30 16:09:52 +0300
committerNick Mathewson <nickm@torproject.org>2020-04-13 14:13:33 -0400
commit37bcc9f3d2f2df0335a42c9692e7d5deafc03514 (patch)
tree5c2cba0051f3461284a08c2e2dbc93d1014202cd /src/feature/control
parente472737297f5924a584fc8f434aba085e89b887a (diff)
downloadtor-37bcc9f3d2f2df0335a42c9692e7d5deafc03514.tar.gz
tor-37bcc9f3d2f2df0335a42c9692e7d5deafc03514.zip
hs-v3: Don't allow registration of an all-zeroes client auth key.
The client auth protocol allows attacker-controlled x25519 private keys being passed around, which allows an attacker to potentially trigger the all-zeroes assert for client_auth_sk in hs_descriptor.c:decrypt_descriptor_cookie(). We fixed that by making sure that an all-zeroes client auth key will not be used. There are no guidelines for validating x25519 private keys, and the assert was there as a sanity check for code flow issues (we don't want to enter that function with an unitialized key if client auth is being used). To avoid such crashes in the future, we also changed the assert to a BUG-and-err.
Diffstat (limited to 'src/feature/control')
-rw-r--r--src/feature/control/control_hs.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/feature/control/control_hs.c b/src/feature/control/control_hs.c
index d3cd363f63..f5b331de9a 100644
--- a/src/feature/control/control_hs.c
+++ b/src/feature/control/control_hs.c
@@ -50,11 +50,18 @@ parse_private_key_from_control_port(const char *client_privkey_str,
if (base64_decode((char*)privkey->secret_key, sizeof(privkey->secret_key),
key_blob,
- strlen(key_blob)) != sizeof(privkey->secret_key)) {
+ strlen(key_blob)) != sizeof(privkey->secret_key)) {
control_printf_endreply(conn, 512, "Failed to decode x25519 private key");
goto err;
}
+ if (fast_mem_is_zero((const char*)privkey->secret_key,
+ sizeof(privkey->secret_key))) {
+ control_printf_endreply(conn, 553,
+ "Invalid private key \"%s\"", key_blob);
+ goto err;
+ }
+
retval = 0;
err: