|
1 | 1 | /** |
2 | 2 | * @name Use of a broken or weak cryptographic algorithm |
3 | 3 | * @description Using broken or weak cryptographic algorithms can compromise security. |
4 | | - * @kind path-problem |
| 4 | + * @kind problem |
5 | 5 | * @problem.severity warning |
6 | 6 | * @security-severity 7.5 |
7 | 7 | * @precision high |
8 | | - * @id go/weak-crypto-algorithm |
| 8 | + * @id go/weak-cryptographic-algorithm |
9 | 9 | * @tags security |
10 | 10 | * external/cwe/cwe-327 |
11 | 11 | * external/cwe/cwe-328 |
12 | 12 | */ |
13 | 13 |
|
14 | 14 | import go |
15 | | -import semmle.go.security.BrokenCryptoAlgorithmQuery |
16 | | -import BrokenCryptoAlgorithmFlow::PathGraph |
17 | 15 |
|
18 | | -from BrokenCryptoAlgorithmFlow::PathNode source, BrokenCryptoAlgorithmFlow::PathNode sink |
19 | | -where BrokenCryptoAlgorithmFlow::flowPath(source, sink) |
20 | | -select sink.getNode(), source, sink, "$@ is used in a weak cryptographic algorithm.", |
21 | | - source.getNode(), "Sensitive data" |
| 16 | +from Cryptography::CryptographicOperation operation, string msgPrefix, DataFlow::Node init |
| 17 | +where |
| 18 | + init = operation.getInitialization() and |
| 19 | + // `init` may be a `BlockModeInit`, a `EncryptionAlgorithmInit`, or `operation` itself. |
| 20 | + ( |
| 21 | + not init instanceof BlockModeInit and |
| 22 | + exists(Cryptography::CryptographicAlgorithm algorithm | |
| 23 | + algorithm = operation.getAlgorithm() and |
| 24 | + algorithm.isWeak() and |
| 25 | + msgPrefix = "The cryptographic algorithm " + algorithm.getName() and |
| 26 | + not algorithm instanceof Cryptography::HashingAlgorithm |
| 27 | + ) |
| 28 | + or |
| 29 | + not init instanceof EncryptionAlgorithmInit and |
| 30 | + operation.getBlockMode().isWeak() and |
| 31 | + msgPrefix = "The block mode " + operation.getBlockMode() |
| 32 | + ) |
| 33 | +select operation, "$@ is broken or weak, and should not be used.", init, msgPrefix |
0 commit comments