SymfonyWorld Online 2021 Winter Edition December 9 – 10, 2021 100% Online +20 talks and workshops

CVE-2016-1902: SecureRandom's fallback not secure when OpenSSL fails

Affected Versions

Symfony 2.3.0 to 2.3.36, 2.6.0 to 2.6.12, 2.7.0 to 2.7.8 versions of the Security component are affected by this security issue when used with PHP 5.x without the paragonie/random_compat library listed in your Composer dependencies. Projects using PHP 7 are not affected.

This issue has been fixed in Symfony 2.3.37, 2.6.13, and 2.7.9. Note that no fixes are provided for Symfony 2.4 and 2.5 as they are not maintained anymore. Symfony 2.8 and 3.0 are not affected.


The SecureRandom Symfony class goal is to generate secure random numbers. Several strategies are used depending on PHP's configuration. On PHP installations where the random_bytes() function is not available, Symfony falls back to using openssl_random_pseudo_bytes(). If that does not work, Symfony generates a secure random number using uniqid() and mt_rand(), which are not suitable for cryptographic contexts.


The fix consists in removing all the custom code in favor of using the paragonie/random_compat library as was already done in Symfony 2.8 and 3.0.

The patch for this issue is available here.


I would like to thank Lander Brandt for reporting this security issue. Thanks to Christian Flothmann for writing the fix for the various Symfony versions.

Manage your notification preferences to receive an email as soon as a Symfony security release is published.
If you have found a security issue in Symfony, please send the details to security [at] and don't disclose it publicly until we can provide a fix for it.
Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.

CVE-2016-1902: SecureRandom's fallback not secure when OpenSSL fails

Tweet this


Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.