https://bz.apache.org/bugzilla/show_bug.cgi?id=70314
Bug ID: 70314
Summary: mod_ssl uses dodgy method of seeding OpenSSL's RNG
with uninitialised memory
Product: Apache httpd-2
Version: 2.5-HEAD
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: mod_ssl
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
When reviewing mod_ssl changes for something else, I noticed a Valgrind commit
to suppress uninitialised memory warnings.
Looking more, modules/ssl/ssl_engine_rand.c has:
```
unsigned char stackdata[256];
[...]
/*
* seed in some current state of the run-time stack (128 bytes)
*/
#if HAVE_VALGRIND
if (ssl_running_on_valgrind) {
VALGRIND_MAKE_MEM_DEFINED(stackdata, sizeof(stackdata));
}
#endif
n = ssl_rand_choosenum(0, sizeof(stackdata)-128-1);
RAND_seed(stackdata+n, 128);
nDone += 128;
```
This isn't safe for a few reasons:
1) it's undefined behaviour, so the standard argument is "anything could
happen" including it being optimised out;
2) there is no guarantee that the stack data is in any way usefully random at
all, or even non-zero. distros are sometimes now building with
-ftrivial-auto-var-init=zero, as GCC's -fhardened does, which means all the
stackdata array would be zero-initialised;
3)
The suppression was added in:
commit 8736e6a6d00beb60c6c7744e22e17c1ccb478e56
Author: Stefan Fritsch <[email protected]>
AuthorDate: Mon Feb 4 19:34:08 2013 +0000
Commit: Stefan Fritsch <[email protected]>
CommitDate: Mon Feb 4 19:34:08 2013 +0000
Avoid valgrind warnings in mod_ssl random number generator
We intentionally add uninitialized stack memory. To avoid warnings,
make valgrind believe that the memory is defined.
Add configure option to enable valgrind support
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1442307
13f79535-47bb-0310-9956-ffa450edef68
But the 'stackdata' use is there from the beginning (perhaps longer in 1.x or
something, not looked into that):
commit f83672781de25207442ff908258219de1d103062
Author: Ralf S. Engelschall <[email protected]>
AuthorDate: Fri May 4 21:54:25 2001 +0000
Commit: Ralf S. Engelschall <[email protected]>
CommitDate: Fri May 4 21:54:25 2001 +0000
Initial revision
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88988
13f79535-47bb-0310-9956-ffa450edef68
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]