Skip to content

Commit 081bad0

Browse files
committed
ecb-cipher-java
1 parent 0970f4f commit 081bad0

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
id: ecb-cipher-java
2+
severity: warning
3+
language: java
4+
message: >-
5+
Cipher in ECB mode is detected. ECB mode produces the same output for
6+
the same input each time which allows an attacker to intercept and replay
7+
the data. Further, ECB mode does not provide any integrity checking. See
8+
https://find-sec-bugs.github.io/bugs.htm#CIPHER_INTEGRITY.
9+
note: >-
10+
[CWE-327] Use of a Broken or Risky Cryptographic Algorithm.
11+
[REFERENCES]
12+
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures
13+
rule:
14+
pattern: Cipher $VAR = $CIPHER.getInstance($MODE);
15+
constraints:
16+
MODE:
17+
regex: .*ECB.*
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
id: ecb-cipher-java
2+
snapshots:
3+
? |
4+
Cipher c = Cipher.getInstance("AES/ECB/NoPadding");
5+
: labels:
6+
- source: Cipher c = Cipher.getInstance("AES/ECB/NoPadding");
7+
style: primary
8+
start: 0
9+
end: 51

tests/java/ecb-cipher-java-test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
id: ecb-cipher-java
2+
valid:
3+
- |
4+
Cipher c = Cipher.getInstance("AES/GCM/NoPadding");
5+
invalid:
6+
- |
7+
Cipher c = Cipher.getInstance("AES/ECB/NoPadding");

0 commit comments

Comments
 (0)