Skip to content

Commit 9d4c5fa

Browse files
author
Sakshis
committed
use-of-rc4-java
1 parent 0e97f58 commit 9d4c5fa

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
id: use-of-rc4-java
2+
language: java
3+
severity: warning
4+
message: >-
5+
'Use of RC4 was detected. RC4 is vulnerable to several attacks,
6+
including stream cipher attacks and bit flipping attacks. Instead, use a
7+
strong, secure cipher: Cipher.getInstance("AES/CBC/PKCS7PADDING"). See
8+
https://owasp.org/www-community/Using_the_Java_Cryptographic_Extensions
9+
for more information.'
10+
note: >-
11+
[CWE-327] Use of a Broken or Risky Cryptographic Algorithm
12+
[REFERENCES]
13+
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures
14+
- https://googleprojectzero.blogspot.com/2022/10/rc4-is-still-considered-harmful.html
15+
rule:
16+
pattern: $CIPHER.getInstance("RC4")
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
id: use-of-rc4-java
2+
snapshots:
3+
? |
4+
Cipher.getInstance("RC4");
5+
: labels:
6+
- source: Cipher.getInstance("RC4")
7+
style: primary
8+
start: 0
9+
end: 25
10+
? |
11+
useCipher(Cipher.getInstance("RC4"));
12+
: labels:
13+
- source: Cipher.getInstance("RC4")
14+
style: primary
15+
start: 10
16+
end: 35

tests/java/use-of-rc4-java-test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
id: use-of-rc4-java
2+
valid:
3+
- |
4+
Cipher.getInstance("AES/CBC/PKCS7PADDING");
5+
invalid:
6+
- |
7+
Cipher.getInstance("RC4");
8+
- |
9+
useCipher(Cipher.getInstance("RC4"));

0 commit comments

Comments
 (0)