Skip to content

Commit d537f86

Browse files
authored
Merge pull request github#12555 from asgerf/js/block-modes
JS: Include weak block modes as sink in weak crypto algorithm
2 parents 9d05d94 + bce1f29 commit d537f86

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/BrokenCryptoAlgorithmCustomizations.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ module BrokenCryptoAlgorithm {
4040
class WeakCryptographicOperationSink extends Sink {
4141
WeakCryptographicOperationSink() {
4242
exists(CryptographicOperation application |
43-
application.getAlgorithm().isWeak() and
43+
(
44+
application.getAlgorithm().isWeak()
45+
or
46+
application.getBlockMode().isWeak()
47+
) and
4448
this = application.getAnInput()
4549
)
4650
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The `js/weak-cryptographic-algorithm` query now flags cryptograhic operations using a weak block mode,
5+
such as AES-ECB.

javascript/ql/test/query-tests/Security/CWE-327/BrokenCryptoAlgorithm.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,23 @@ nodes
1111
| tst.js:19:17:19:24 | password |
1212
| tst.js:19:17:19:24 | password |
1313
| tst.js:19:17:19:24 | password |
14+
| tst.js:22:21:22:30 | secretText |
15+
| tst.js:22:21:22:30 | secretText |
16+
| tst.js:22:21:22:30 | secretText |
1417
edges
1518
| tst.js:3:5:3:24 | secretText | tst.js:11:17:11:26 | secretText |
1619
| tst.js:3:5:3:24 | secretText | tst.js:11:17:11:26 | secretText |
20+
| tst.js:3:5:3:24 | secretText | tst.js:22:21:22:30 | secretText |
21+
| tst.js:3:5:3:24 | secretText | tst.js:22:21:22:30 | secretText |
1722
| tst.js:3:18:3:24 | trusted | tst.js:3:5:3:24 | secretText |
1823
| tst.js:3:18:3:24 | trusted | tst.js:3:5:3:24 | secretText |
1924
| tst.js:11:17:11:26 | secretText | tst.js:11:17:11:26 | secretText |
2025
| tst.js:17:17:17:25 | o.trusted | tst.js:17:17:17:25 | o.trusted |
2126
| tst.js:19:17:19:24 | password | tst.js:19:17:19:24 | password |
27+
| tst.js:22:21:22:30 | secretText | tst.js:22:21:22:30 | secretText |
2228
#select
2329
| tst.js:11:17:11:26 | secretText | tst.js:3:18:3:24 | trusted | tst.js:11:17:11:26 | secretText | A broken or weak cryptographic algorithm depends on $@. | tst.js:3:18:3:24 | trusted | sensitive data froman access to trusted |
2430
| tst.js:11:17:11:26 | secretText | tst.js:11:17:11:26 | secretText | tst.js:11:17:11:26 | secretText | A broken or weak cryptographic algorithm depends on $@. | tst.js:11:17:11:26 | secretText | sensitive data froman access to secretText |
2531
| tst.js:17:17:17:25 | o.trusted | tst.js:17:17:17:25 | o.trusted | tst.js:17:17:17:25 | o.trusted | A broken or weak cryptographic algorithm depends on $@. | tst.js:17:17:17:25 | o.trusted | sensitive data froman access to trusted |
32+
| tst.js:22:21:22:30 | secretText | tst.js:3:18:3:24 | trusted | tst.js:22:21:22:30 | secretText | A broken or weak cryptographic algorithm depends on $@. | tst.js:3:18:3:24 | trusted | sensitive data froman access to trusted |
33+
| tst.js:22:21:22:30 | secretText | tst.js:22:21:22:30 | secretText | tst.js:22:21:22:30 | secretText | A broken or weak cryptographic algorithm depends on $@. | tst.js:22:21:22:30 | secretText | sensitive data froman access to secretText |

javascript/ql/test/query-tests/Security/CWE-327/tst.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ unknownCipher.update(secretText, 'utf8', 'hex'); // OK: unknown algorithm
1717
desCipher.write(o.trusted, 'utf8', 'hex'); // BAD
1818

1919
desCipher.write(password, 'utf8', 'hex'); // OK (flagged by js/insufficient-password-hash)
20+
21+
const aesEcbCipher = crypto.createCipher('aes-128-ecb', key);
22+
aesEcbCipher.update(secretText, 'utf8', 'hex'); // BAD

0 commit comments

Comments
 (0)