[issue18747] Re-seed OpenSSL's PRNG after fork

2019-01-04 Thread Christian Heimes
Christian Heimes added the comment: I have no plans to work on the issue any more. OpenSSL 1.1.1 has fixed the RNG issue with a new DRBG implementation. Eventually all platforms will move to 1.1.1 because it also provides TLS 1.3. In the mean time, application can work around the limitation

[issue18747] Re-seed OpenSSL's PRNG after fork

2019-01-04 Thread STINNER Victor
STINNER Victor added the comment: The issue is closed. If you want to change anything, please open a new issue. IMHO this issue is too long, it's better to start a fresh issue with up to date info, just mention this old issue: bpo-18747. -- ___

[issue18747] Re-seed OpenSSL's PRNG after fork

2019-01-04 Thread Gabriel Corona
Gabriel Corona added the comment: Now that the default PRNG of the 'random' package is automatically reseeded at fork, wouldn't it make sense to reseed the OpenSSL seed as well? (At the same time the OpenSSL wiki states [1] that "The situation has changed greatly, starting with OpenSSL

[issue18747] Re-seed OpenSSL's PRNG after fork

2014-09-30 Thread Georg Brandl
Changes by Georg Brandl ge...@python.org: -- versions: -Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747 ___ ___ Python-bugs-list

[issue18747] Re-seed OpenSSL's PRNG after fork

2014-09-30 Thread Roundup Robot
Roundup Robot added the comment: New changeset bdf73458df5f by Christian Heimes in branch '3.2': Issue #18747: document issue with OpenSSL's CPRNG state and fork https://hg.python.org/cpython/rev/bdf73458df5f -- ___ Python tracker

[issue18747] Re-seed OpenSSL's PRNG after fork

2014-09-30 Thread Georg Brandl
Changes by Georg Brandl ge...@python.org: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747 ___

[issue18747] Re-seed OpenSSL's PRNG after fork

2014-09-30 Thread Berker Peksag
Changes by Berker Peksag berker.pek...@gmail.com: -- stage: commit review - resolved ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747 ___ ___

[issue18747] Re-seed OpenSSL's PRNG after fork

2014-07-03 Thread Mark Lawrence
Mark Lawrence added the comment: Is this really an enhancement request or should it be a security issue? Which versions if any actually need work doing on them? -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org

[issue18747] Re-seed OpenSSL's PRNG after fork

2014-03-16 Thread Jeffrey Walton
Jeffrey Walton added the comment: It probably is an OpenSSL bug but the declaration doesn't help us. It's not the first time Python has to work around OpenSSL, e.g. #18709. Sorry to dig up an old issue. But here's some reading on it if interested. Ben Laurire pushed a patch to mix in PID and

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-11-17 Thread Roundup Robot
Roundup Robot added the comment: New changeset 4e6aa98bb11c by Christian Heimes in branch '3.3': Issue #19227 / Issue #18747: Remove pthread_atfork() handler to remove OpenSSL re-seeding http://hg.python.org/cpython/rev/4e6aa98bb11c -- ___ Python

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-10-29 Thread Roundup Robot
Roundup Robot added the comment: New changeset 5942eea8cf41 by Christian Heimes in branch '3.3': Issue #19227 / Issue #18747: Remove pthread_atfork() handler to remove OpenSSL re-seeding http://hg.python.org/cpython/rev/5942eea8cf41 New changeset cd4007fb9c7e by Christian Heimes in branch

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-10-29 Thread Roundup Robot
Roundup Robot added the comment: New changeset ad779da9e351 by Christian Heimes in branch '2.7': Issue #19227 / Issue #18747: Remove pthread_atfork() handler to remove OpenSSL re-seeding http://hg.python.org/cpython/rev/ad779da9e351 -- ___ Python

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-10-27 Thread Georg Brandl
Georg Brandl added the comment: #19227 must be solved before anything is backported to the security branches. -- dependencies: +test_multiprocessing_xxx hangs under Gentoo buildbots ___ Python tracker rep...@bugs.python.org

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-10-27 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747 ___

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-10-19 Thread Christian Heimes
Christian Heimes added the comment: It's considered fixed but we have seen issues. The issues are tracked in #19227. AFAIK the fixed hasn't landed in 3.2 yet. I'm removing 2,7, 3.3 and 3.4 from the versions list. -- versions: -Python 2.7, Python 3.3, Python 3.4

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-10-19 Thread Charles-François Natali
Charles-François Natali added the comment: Well, I don't mean to be a pain, but I still think this patch shouldn't have been applied: it makes fork() not async-safe, which can trigger hard to debug, random bugs (#19227 might or might not be a direct consequence). at the very least, I still it

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-10-18 Thread Larry Hastings
Larry Hastings added the comment: I can't follow all this. Is this considered fixed in 3.4 or not? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747 ___

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-09-15 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: After further contemplation and without objection from __ap__ and Crys on IRC, I am de-targeting this for 2.6. I won't apply it for 2.6.9. -- versions: -Python 2.6 ___ Python tracker rep...@bugs.python.org

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-09-03 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: blocker for 2.6.9 -- nosy: +larry priority: normal - release blocker ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747 ___

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-25 Thread Roundup Robot
Roundup Robot added the comment: New changeset 8b962e831ff0 by Christian Heimes in branch '3.3': Issue #18747: Fix spelling errors in my commit message and comments, http://hg.python.org/cpython/rev/8b962e831ff0 New changeset 7b1da249ab6d by Christian Heimes in branch 'default': Issue #18747:

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-23 Thread STINNER Victor
STINNER Victor added the comment: Oh i forgot that i wrote a patch for openssl: https://bitbucket.org/haypo/hasard/src/tip/patches/openssl_rand_fork.patch -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-22 Thread Roundup Robot
Roundup Robot added the comment: New changeset 39c9dbed3aa1 by Christian Heimes in branch '3.3': Issue #18747: Use a parent atfork handler instead of a child atfork handler. http://hg.python.org/cpython/rev/39c9dbed3aa1 New changeset 25e05147d662 by Christian Heimes in branch 'default': Issue

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-22 Thread Vajrasky Kok
Vajrasky Kok added the comment: Some typos on last commit current time (miliseconds or seconds) and an uninitialized arry. should be current time (miliseconds or seconds) and an uninitialized array. instead of a child handler because fork() is suppose to be async-signal should be

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-22 Thread Christian Heimes
Christian Heimes added the comment: Thanks, that's embarrassing. :( I'm going to install a spell checker ... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747 ___

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-22 Thread STINNER Victor
STINNER Victor added the comment: PySSL_RAND_atfork_parent() still uses getpid(). This number is not very random in the *parent* process :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-22 Thread Charles-François Natali
Charles-François Natali added the comment: STINNER Victor added the comment: PySSL_RAND_atfork_parent() still uses getpid(). This number is not very random in the *parent* process :-) :-) IMO this patch has been rushed in and should be reverted for now. It's still not async-signal safe,

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-22 Thread STINNER Victor
STINNER Victor added the comment: IMO this patch has been rushed in and should be reverted for now. Agreed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747 ___

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-22 Thread Christian Heimes
Christian Heimes added the comment: Am 22.08.2013 15:20, schrieb STINNER Victor: STINNER Victor added the comment: PySSL_RAND_atfork_parent() still uses getpid(). This number is not very random in the *parent* process :-) That's fine and doesn't diminish the properties of the PRNG. In

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-22 Thread Christian Heimes
Christian Heimes added the comment: Yet another good blog post about the issue: OpenSSL PRNG Is Not (Really) Fork-safe http://emboss.github.io/blog/2013/08/21/openssl-prng-is-not-really-fork-safe/ -- ___ Python tracker rep...@bugs.python.org

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-22 Thread Antoine Pitrou
Antoine Pitrou added the comment: IMO this patch has been rushed in and should be reverted for now. It's still not async-signal safe, had typos, plus this problem noted by Victor. That's not really a problem. You merely have to *perturb* the random state in the parent, so that the next child

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-22 Thread Charles-François Natali
Charles-François Natali added the comment: PySSL_RAND_atfork_parent() still uses getpid(). This number is not very random in the *parent* process :-) That's fine and doesn't diminish the properties of the PRNG. In fact the patch could use a hard coded value to perturb the PRNG. It's only

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-22 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: On Aug 21, 2013, at 11:49 AM, Christian Heimes wrote: I have taken care of Antoine's and Victor's reviews. The fix has landed in Python 2.7, 3.3 and 3.4. What about 2.6, 3.1 and 3.2? After all it's a security fix (although I don't consider its severity as

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-21 Thread Roundup Robot
Roundup Robot added the comment: New changeset 8e1194c39bed by Christian Heimes in branch '3.3': Issue #18747: Re-seed OpenSSL's pseudo-random number generator after fork. http://hg.python.org/cpython/rev/8e1194c39bed New changeset 49e23a3adf26 by Christian Heimes in branch 'default': Issue

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-21 Thread Christian Heimes
Christian Heimes added the comment: I have taken care of Antoine's and Victor's reviews. The fix has landed in Python 2.7, 3.3 and 3.4. What about 2.6, 3.1 and 3.2? After all it's a security fix (although I don't consider its severity as high). -- nosy: +barry, benjamin.peterson,

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-21 Thread STINNER Victor
STINNER Victor added the comment: 3.52 +#if 0 3.53 +fprintf(stderr, PySSL_RAND_atfork_child() seeds %i bytes in pid %i\n, 3.54 +(int)sizeof(seed), seed.pid); 3.55 +#endif Don't you want to remove this debug code? 1.8 +def test_random_fork(self): 1.9 +

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-21 Thread Charles-François Natali
Charles-François Natali added the comment: Christian Heimes added the comment: I have taken care of Antoine's and Victor's reviews. The fix has landed in Python 2.7, 3.3 and 3.4. What about 2.6, 3.1 and 3.2? After all it's a security fix (although I don't consider its severity as high).

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-21 Thread Christian Heimes
Christian Heimes added the comment: Am 21.08.2013 14:08, schrieb Charles-François Natali: And basically, because PySSL_RAND_atfork_child() is not async-signal safe, the interpreter is now subject to random deadlocks/crash in multi-threaded processes. I personally don't consider this a

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-21 Thread Charles-François Natali
Charles-François Natali added the comment: Which part of the function is not async-signal safe? It doesn't interact with any file descriptors nor does it use any syscalls except for getpid() and time(). gettimeofday() and RAND_add() The functions which are guaranteed to be async-signal safe

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-21 Thread Christian Heimes
Christian Heimes added the comment: Do you have a proposal for a better way to fix the issue? I don't think that we can hope for a fix from OpenSSL. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: Do you have a proposal for a better way to fix the issue? I don't think that we can hope for a fix from OpenSSL. Instead of reseeding in the child, you can perturb the state in the parent after fork. As far as I understand, only the child callback in

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-21 Thread Charles-François Natali
Charles-François Natali added the comment: 2013/8/21 Antoine Pitrou rep...@bugs.python.org: Instead of reseeding in the child, you can perturb the state in the parent after fork. As far as I understand, only the child callback in pthread_atfork() needs to be async-signal-safe: That's not

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-21 Thread Richard Oudkerk
Richard Oudkerk added the comment: On 21/08/2013 3:46pm, Charles-François Natali wrote: Another, probably cleaner way would be to finally add the atfork() module (issue #16500), and register this reseed hook (which could then be implemented in ssl.py). Wouldn't that still suffer from the

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: [snip insightful explanation] So it's not really safe either, although the window is narrower. Gosh. Well, the narrower window would be fine with me :-) -- ___ Python tracker rep...@bugs.python.org

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-21 Thread Christian Heimes
Christian Heimes added the comment: Oh heck, signal, threads and fork really don't mix. :( Under which condition can a non-async safe function cause trouble? Is it just fork() inside a signal handler or can an incoming signal during fork() also cause havoc? The OpenSSL PRNG is only buggy when

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-21 Thread Charles-François Natali
Charles-François Natali added the comment: Another, probably cleaner way would be to finally add the atfork() module (issue #16500), and register this reseed hook (which could then be implemented in ssl.py). Wouldn't that still suffer from the double-fork() issue? Not for the officially

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-20 Thread Christian Heimes
Christian Heimes added the comment: Thanks Victor, it sounds like a good suggestion. I have modified my patch to use _PyTime_gettimeofday(). Python 2.7 doesn't have _PyTime_gettimeofday() so I'm going to use time(NULL). -- Added file:

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-20 Thread Christian Heimes
Changes by Christian Heimes li...@cheimes.de: Removed file: http://bugs.python.org/file31389/openssl_prng_atfork5.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747 ___

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-20 Thread Christian Heimes
Changes by Christian Heimes li...@cheimes.de: Added file: http://bugs.python.org/file31390/openssl_prng_atfork5.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747 ___

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-20 Thread STINNER Victor
STINNER Victor added the comment: openssl_prng_atfork5.patch: - you should use RAND_pseudo_bytes() instead of RAND_bytes() in the unit test, to not skip the test depending on the entropy - the change in Misc/NEWS is strange - please remove dead code (#if 0) - PySSL_RAND_atfork_child() comment

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-18 Thread Christian Heimes
Christian Heimes added the comment: The lastest patch mixes seconds into the time field of seed. Python 3.3+ support only NT and POSIX threads. 2.7 and 3.2 have GNU pth and other threading API but I neither have a system to test other threading libs nor the motivation to port my patch to an

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-18 Thread STINNER Victor
STINNER Victor added the comment: PySSL_RAND_atfork_child(void) can be simplified by calling _PyTime_gettimeofday(). This function uses the most(*) accurate function and already implements fallbacks on error. (*) _PyTime_gettimeofday() does not use clock_gettime() because of a linker issue:

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-17 Thread Christian Heimes
Christian Heimes added the comment: Here is a patch that is based on Apache's mod_ssl code. mod_ssl perturbs the PRNG state more often but I think that's overkill for Python. The new patch only affects the PRNG state of the child process. In my opinion it is the better way to solve this

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-17 Thread Antoine Pitrou
Antoine Pitrou added the comment: The patch looks fine on the principle, but you should add a test. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747 ___

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-17 Thread Charles-François Natali
Charles-François Natali added the comment: 2013/8/17 Christian Heimes rep...@bugs.python.org: Here is a patch that is based on Apache's mod_ssl code. mod_ssl perturbs the PRNG state more often but I think that's overkill for Python. The new patch only affects the PRNG state of the child

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-17 Thread STINNER Victor
STINNER Victor added the comment: openssl_prng_atfork3.patch: Why not using seconds (only micro or nanoseconds) in the seed? Add a few more bits should not reduce the entropy. OpenSSL does hash all these bytes anyway. +#if 1 +fprintf(stderr, PySSL_RAND_atfork_child() seeds %i bytes in %i\n,

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-15 Thread Christian Heimes
New submission from Christian Heimes: A couple of reports and check-in messages like Postgres / pgcrypto CVE-2013-1900 http://bugs.ruby-lang.org/issues/4579 http://www.exim.org/lurker/message/20130402.171710.92f14a60.fi.html suggests that OpenSSL's PRNG should be reset or re-seeded after

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: Are there any uses of the OpenSSL PRNG from Python? Is the PRNG used for SSL session keys, or another mechanism? -- nosy: +pitrou, sbt type: security - enhancement versions: -Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-15 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +neologix ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747 ___ ___ Python-bugs-list mailing

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-15 Thread Christian Heimes
Christian Heimes added the comment: The ssl module exposes OpenSSL's PRNG and advertises the API as secure CPRNG: http://docs.python.org/3/library/ssl.html#random-generation OpenSSL uses its own PRNG to create (amongst others) session keys for SSL connections. --

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: The ssl module exposes OpenSSL's PRNG and advertises the API as secure CPRNG: http://docs.python.org/3/library/ssl.html#random-generation AFAICT, Python's PRNG isn't reset after fork, so I don't think OpenSSL's should be reset. OTOH, multiprocessing does

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-15 Thread Christian Heimes
Christian Heimes added the comment: Python doesn't have a builtin PRNG. We use the OS's CPRNG such as /dev/urandom or CryptGenRandom(). Both use a system wide state and are not affected by process state. OpenSSL's PRNG is different because it uses an internal state. AFAIK it only polls the

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: Python doesn't have a builtin PRNG. Of course it does. It's in the random module, and you can seed() it: random.seed(5) random.random() 0.6229016948897019 random.random() 0.7417869892607294 random.seed(5) random.random() 0.6229016948897019 See e.g.

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-15 Thread Christian Heimes
Christian Heimes added the comment: Am 15.08.2013 15:14, schrieb Antoine Pitrou: Python doesn't have a builtin PRNG. Of course it does. It's in the random module, and you can seed() it: Now you are nit-picking. Although random is a PRNG, it is not a CPRNG. I'm clearly talking about the

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: When the OpenSSL's CPRNG is already initialized before 3) than all child processes created by 3) will have almost the same PRNG state. According to http://bugs.ruby-lang.org/issues/4579 the PRNG will return the same value when PID numbers are recycled.

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-15 Thread STINNER Victor
STINNER Victor added the comment: This issue was already discussed in the atfork issue: http://bugs.python.org/issue16500#msg179838 See also: http://www.openwall.com/lists/oss-security/2013/04/12/3 I believe it is wrong to fix this in PostgreSQL. Rather, this is a bug in the OpenSSL fork

[issue18747] Re-seed OpenSSL's PRNG after fork

2013-08-15 Thread STINNER Victor
STINNER Victor added the comment: Another link: http://article.gmane.org/gmane.comp.encryption.openssl.user/48480/match=does+child+process+still+need+reseeded+after+fork -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18747