|
| 1 | +<!DOCTYPE qhelp PUBLIC |
| 2 | +"-//Semmle//qhelp//EN" |
| 3 | +"qhelp.dtd"> |
| 4 | +<qhelp> |
| 5 | + <overview> |
| 6 | + <p> |
| 7 | + Using broken or weak cryptographic algorithms can leave data |
| 8 | + vulnerable to being decrypted or forged by an attacker. |
| 9 | + </p> |
| 10 | + |
| 11 | + <p> |
| 12 | + Many cryptographic algorithms provided by cryptography |
| 13 | + libraries are known to be weak, or flawed. Using such an |
| 14 | + algorithm means that encrypted or hashed data is less |
| 15 | + secure than it appears to be. |
| 16 | + </p> |
| 17 | + |
| 18 | + <p> |
| 19 | + This query alerts on any use of a weak cryptographic algorithm, that is |
| 20 | + not a hashing algorithm. Use of broken or weak cryptographic hash |
| 21 | + functions are handled by the |
| 22 | + <code>rust/weak-sensitive-data-hashing</code> query. |
| 23 | + </p> |
| 24 | + |
| 25 | + </overview> |
| 26 | + <recommendation> |
| 27 | + |
| 28 | + <p> |
| 29 | + Ensure that you use a strong, modern cryptographic |
| 30 | + algorithm, such as AES-128 or RSA-2048. |
| 31 | + </p> |
| 32 | + |
| 33 | + </recommendation> |
| 34 | + <example> |
| 35 | + |
| 36 | + <p> |
| 37 | + The following code uses the <code>des</code> crate from the |
| 38 | + <code>RustCrypto</code> family to encrypt some secret data. The |
| 39 | + DES algorithm is old and considered very weak. |
| 40 | + </p> |
| 41 | + |
| 42 | + <sample src="BrokenCryptoAlgorithmBad.rs" /> |
| 43 | + |
| 44 | + <p> |
| 45 | + Instead we should use a strong modern algorithm. In this |
| 46 | + case we have selected the 256-bit version of the AES |
| 47 | + algorithm. |
| 48 | + </p> |
| 49 | + |
| 50 | + <sample src="BrokenCryptoAlgorithmGood.rs" /> |
| 51 | + |
| 52 | + </example> |
| 53 | + |
| 54 | + <references> |
| 55 | + <li>NIST, FIPS 140 Annex a: <a href="http://csrc.nist.gov/publications/fips/fips140-2/fips1402annexa.pdf"> Approved Security Functions</a>.</li> |
| 56 | + <li>NIST, SP 800-131A: <a href="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar1.pdf"> Transitions: Recommendation for Transitioning the Use of Cryptographic Algorithms and Key Lengths</a>.</li> |
| 57 | + <li>OWASP: <a |
| 58 | + href="https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html#algorithms"> Cryptographic Storage Cheat Sheet - Algorithms</a>. |
| 59 | + </li> |
| 60 | + </references> |
| 61 | + |
| 62 | +</qhelp> |
0 commit comments