|
1 |
| -<p>Using pseudorandom number generators (PRNGs) is security-sensitive. For example, it has led in the past to the following vulnerabilities:</p> |
| 1 | +<p>PRNGs are algorithms that produce sequences of numbers that only approximate true randomness. While they are suitable for applications like |
| 2 | +simulations or modeling, they are not appropriate for security-sensitive contexts because their outputs can be predictable if the internal state is |
| 3 | +known.</p> |
| 4 | +<p>In contrast, cryptographically secure pseudorandom number generators (CSPRNGs) are designed to be secure against prediction attacks. CSPRNGs use |
| 5 | +cryptographic algorithms to ensure that the generated sequences are not only random but also unpredictable, even if part of the sequence or the |
| 6 | +internal state becomes known. This unpredictability is crucial for security-related tasks such as generating encryption keys, tokens, or any other |
| 7 | +values that must remain confidential and resistant to guessing attacks.</p> |
| 8 | +<p>For example, the use of non-cryptographic PRNGs has led to vulnerabilities such as:</p> |
2 | 9 | <ul>
|
3 | 10 | <li> <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-6386">CVE-2013-6386</a> </li>
|
4 | 11 | <li> <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-3419">CVE-2006-3419</a> </li>
|
5 | 12 | <li> <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-4102">CVE-2008-4102</a> </li>
|
6 | 13 | </ul>
|
7 | 14 | <p>When software generates predictable values in a context requiring unpredictability, it may be possible for an attacker to guess the next value that
|
8 |
| -will be generated, and use this guess to impersonate another user or access sensitive information.</p> |
| 15 | +will be generated, and use this guess to impersonate another user or access sensitive information. Therefore, it is critical to use CSPRNGs in any |
| 16 | +security-sensitive application to ensure the robustness and security of the system.</p> |
9 | 17 | <h2>Ask Yourself Whether</h2>
|
10 | 18 | <ul>
|
11 | 19 | <li> the code using the generated value requires it to be unpredictable. It is the case for all encryption mechanisms or when a secret value, such
|
12 | 20 | as a password, is hashed. </li>
|
13 |
| - <li> the function you use generates a value which can be predicted (pseudo-random). </li> |
| 21 | + <li> the function you use is a non-cryptographic PRNG. </li> |
14 | 22 | <li> the generated value is used multiple times. </li>
|
15 | 23 | <li> an attacker can access the generated value. </li>
|
16 | 24 | </ul>
|
@@ -38,10 +46,12 @@ <h2>Sensitive Code Example</h2>
|
38 | 46 | </pre>
|
39 | 47 | <h2>See</h2>
|
40 | 48 | <ul>
|
| 49 | + <li> OWASP - <a href="https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html#secure-random-number-generation">Secure |
| 50 | + Random Number Generation Cheat Sheet</a> </li> |
41 | 51 | <li> OWASP - <a href="https://owasp.org/Top10/A02_2021-Cryptographic_Failures/">Top 10 2021 Category A2 - Cryptographic Failures</a> </li>
|
42 | 52 | <li> OWASP - <a href="https://owasp.org/www-project-top-ten/2017/A3_2017-Sensitive_Data_Exposure">Top 10 2017 Category A3 - Sensitive Data
|
43 | 53 | Exposure</a> </li>
|
44 |
| - <li> <a href="https://mas.owasp.org/checklists/MASVS-CRYPTO/">Mobile AppSec Verification Standard - Cryptography Requirements</a> </li> |
| 54 | + <li> OWASP - <a href="https://mas.owasp.org/checklists/MASVS-CRYPTO/">Mobile AppSec Verification Standard - Cryptography Requirements</a> </li> |
45 | 55 | <li> OWASP - <a href="https://owasp.org/www-project-mobile-top-10/2016-risks/m5-insufficient-cryptography">Mobile Top 10 2016 Category M5 -
|
46 | 56 | Insufficient Cryptography</a> </li>
|
47 | 57 | <li> CWE - <a href="https://cwe.mitre.org/data/definitions/338">CWE-338 - Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)</a>
|
|
0 commit comments