From f9a05e464de9b876f21c1fc5563ef628b9057fe8 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 17 May 2021 08:50:01 -0400 Subject: [PATCH 1/2] Assert on _all_ failures from RAND_bytes(). Previously, we would detect errors from a missing RNG implementation, but not failures from the RNG code itself. Fortunately, it appears those failures do not happen in practice when Tor is using OpenSSL's default RNG implementation. Fixes bug 40390; bugfix on 0.2.8.1-alpha. This issue is also tracked as TROVE-2021-004. Reported by Jann Horn at Google's Project Zero. --- src/lib/crypt_ops/crypto_rand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/crypt_ops/crypto_rand.c b/src/lib/crypt_ops/crypto_rand.c index 915fe0870d..206929d6b3 100644 --- a/src/lib/crypt_ops/crypto_rand.c +++ b/src/lib/crypt_ops/crypto_rand.c @@ -525,7 +525,7 @@ crypto_rand_unmocked(char *to, size_t n) /* We consider a PRNG failure non-survivable. Let's assert so that we get a * stack trace about where it happened. */ - tor_assert(r >= 0); + tor_assert(r == 1); #endif } From ee35291a7cdbe51038cbc21ddd5605d7d11c0b94 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 18 May 2021 08:30:47 -0400 Subject: [PATCH 2/2] fixup! Assert on _all_ failures from RAND_bytes(). Whoops; I forgot to add the changes file. :/ --- changes/ticket40390 | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 changes/ticket40390 diff --git a/changes/ticket40390 b/changes/ticket40390 new file mode 100644 index 0000000000..b56fa4d9da --- /dev/null +++ b/changes/ticket40390 @@ -0,0 +1,8 @@ + o Major bugfixes (security, defense-in-depth): + - Detect a wider variety of failure conditions from the OpenSSL RNG + code. Previously, we would detect errors from a missing RNG + implementation, but not failures from the RNG code itself. + Fortunately, it appears those failures do not happen in practice + when Tor is using OpenSSL's default RNG implementation. + Fixes bug 40390; bugfix on 0.2.8.1-alpha. This issue is also tracked as + TROVE-2021-004. Reported by Jann Horn at Google's Project Zero.