reseed OpenSSL PRNG upon fork() of workers
commit1107ede716461049033d6a5b311e14c742c9363a
authorEric Wong <normalperson@yhbt.net>
Mon, 18 Apr 2011 22:34:29 +0000 (18 15:34 -0700)
committerEric Wong <normalperson@yhbt.net>
Mon, 18 Apr 2011 22:45:22 +0000 (18 15:45 -0700)
tree5a121be9cbd53662ac9e643b15df85b2a52cac70
parentb32416211ef30e958ec38c8c99833161cd476dd4
reseed OpenSSL PRNG upon fork() of workers

OpenSSL seeds its PRNG with the process ID, so if a process ID
is recycled, there's a chance of indepedent workers getting
repeated PRNG sequences over a long time period iff the same
PID is used.

This only affects deployments that meet both of the following
conditions:

1) OpenSSL::Random.random_bytes is called before forking
2) worker (but not master) processes are die unexpectedly

The SecureRandom module in Ruby (and Rails) uses the OpenSSL
PRNG if available.  SecureRandom is used by Rails and called
when the application is loaded, so most Rails apps with
frequently dying worker processes are affected.

Of course dying worker processes are bad and entirely the
fault of bad application/library code, not the fault of
Unicorn.

Thanks for Alexander Dymo for reporting this.

ref: http://redmine.ruby-lang.org/issues/4579
lib/unicorn/http_server.rb