forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBrokenCryptoAlgorithm.qhelp
More file actions
74 lines (61 loc) · 2.43 KB
/
BrokenCryptoAlgorithm.qhelp
File metadata and controls
74 lines (61 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
Using broken or weak cryptographic algorithms may compromise
security guarantees such as confidentiality, integrity, and
authenticity.
</p>
<p>
Many cryptographic algorithms are known to be weak or flawed. The
security guarantees of a system often rely on the underlying
cryptography, so using a weak algorithm can have severe consequences.
For example:
</p>
<ul>
<li>
If a weak encryption algorithm is used, an attacker may be able to
decrypt sensitive data.
</li>
<li>
If a weak algorithm is used for digital signatures, an attacker may
be able to forge signatures and impersonate legitimate users.
</li>
</ul>
<p>
This query alerts on any use of a weak cryptographic algorithm that is
not a hashing algorithm. Use of broken or weak cryptographic hash
functions are handled by the
<code>rust/weak-sensitive-data-hashing</code> query.
</p>
</overview>
<recommendation>
<p>
Ensure that you use a strong, modern cryptographic
algorithm, such as AES-128 or RSA-2048.
</p>
</recommendation>
<example>
<p>
The following code uses the <code>des</code> crate from the
<code>RustCrypto</code> family to encrypt some secret data. The
DES algorithm is old and considered very weak.
</p>
<sample src="BrokenCryptoAlgorithmBad.rs" />
<p>
Instead, we should use a strong modern algorithm. In this
case, we have selected the 256-bit version of the AES
algorithm.
</p>
<sample src="BrokenCryptoAlgorithmGood.rs" />
</example>
<references>
<li>NIST, FIPS 140 Annex A: <a href="http://csrc.nist.gov/publications/fips/fips140-2/fips1402annexa.pdf"> Approved Security Functions</a>.</li>
<li>NIST, SP 800-131A Revision 2: <a href="https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf">Transitioning the Use of Cryptographic Algorithms and Key Lengths</a>.</li>
<li>OWASP: <a
href="https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html#algorithms"> Cryptographic Storage Cheat Sheet - Algorithms</a>.
</li>
</references>
</qhelp>