Skip to content

Commit

Permalink
Add functional categories to Java cryptographic rules (#3157) (#3158)
Browse files Browse the repository at this point in the history
* Add functional categories to Java cryptographic rules

* Add library tags to Java crypto rule functional categories

Co-authored-by: Pieter De Cremer (Semgrep) <pieter@r2c.dev>
  • Loading branch information
r2c-argo[bot] and 0xDC0DE authored Oct 12, 2023
1 parent e1d7ccf commit fc0871c
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/des-is-deprecated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ rules:
See https://www.nist.gov/news-events/news/2005/06/nist-withdraws-outdated-data-encryption-standard
for more information.
metadata:
functional-categories:
- 'crypto::search::symmetric-algorithm::javax.crypto'
cwe:
- 'CWE-326: Inadequate Encryption Strength'
owasp:
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/desede-is-deprecated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ rules:
Triple DES (3DES or DESede) is considered deprecated. AES is the recommended cipher.
Upgrade to use AES.
metadata:
functional-categories:
- 'crypto::search::symmetric-algorithm::javax.crypto'
cwe:
- 'CWE-326: Inadequate Encryption Strength'
owasp:
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/ecb-cipher.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
rules:
- id: ecb-cipher
metadata:
functional-categories:
- 'crypto::search::mode::javax.crypto'
cwe:
- 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
owasp:
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/gcm-detection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ rules:
- id: gcm-detection
metadata:
category: security
functional-categories:
- 'crypto::search::randomness::javax.crypto'
cwe:
- 'CWE-323: Reusing a Nonce, Key Pair in Encryption'
references:
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/gcm-nonce-reuse.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
rules:
- id: gcm-nonce-reuse
metadata:
functional-categories:
- 'crypto::search::randomness::javax.crypto'
cwe:
- 'CWE-323: Reusing a Nonce, Key Pair in Encryption'
category: security
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/rsa-no-padding.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
rules:
- id: rsa-no-padding
metadata:
functional-categories:
- 'crypto::search::mode::javax.crypto'
cwe:
- 'CWE-326: Inadequate Encryption Strength'
owasp:
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/unencrypted-socket.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
rules:
- id: unencrypted-socket
metadata:
functional-categories:
- 'net::search::crypto-config::java.net'
cwe:
- 'CWE-319: Cleartext Transmission of Sensitive Information'
owasp:
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/use-of-aes-ecb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ rules:
- id: use-of-aes-ecb
pattern: $CIPHER.getInstance("=~/AES/ECB.*/")
metadata:
functional-categories:
- 'crypto::search::mode::javax.crypto'
cwe:
- 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
owasp:
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/use-of-blowfish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ rules:
- id: use-of-blowfish
pattern: $CIPHER.getInstance("Blowfish")
metadata:
functional-categories:
- 'crypto::search::symmetric-algorithm::javax.crypto'
cwe:
- 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
owasp:
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/use-of-default-aes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ rules:
- pattern: Cipher.getInstance("AES")
- pattern: (Cipher $CIPHER).getInstance("AES")
metadata:
functional-categories:
- 'crypto::search::mode::javax.crypto'
cwe:
- "CWE-327: Use of a Broken or Risky Cryptographic Algorithm"
owasp:
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/use-of-md5-digest-utils.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ rules:
languages: [java]
severity: WARNING
metadata:
functional-categories:
- 'crypto::search::hash-algorithm::org.apache.commons'
owasp:
- A03:2017 - Sensitive Data Exposure
- A02:2021 - Cryptographic Failures
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/use-of-md5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ rules:
languages: [java]
severity: WARNING
metadata:
functional-categories:
- 'crypto::search::hash-algorithm::java.security'
owasp:
- A03:2017 - Sensitive Data Exposure
- A02:2021 - Cryptographic Failures
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/use-of-rc2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ rules:
- id: use-of-rc2
pattern: $CIPHER.getInstance("RC2")
metadata:
functional-categories:
- 'crypto::search::symmetric-algorithm::javax.crypto'
cwe:
- 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
owasp:
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/use-of-rc4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ rules:
- id: use-of-rc4
pattern: $CIPHER.getInstance("RC4")
metadata:
functional-categories:
- 'crypto::search::symmetric-algorithm::javax.crypto'
cwe:
- 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
owasp:
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/use-of-sha1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ rules:
languages: [java]
severity: WARNING
metadata:
functional-categories:
- 'crypto::search::hash-algorithm::javax.crypto'
owasp:
- A03:2017 - Sensitive Data Exposure
- A02:2021 - Cryptographic Failures
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/weak-random.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ rules:
languages: [java]
severity: WARNING
metadata:
functional-categories:
- 'crypto::search::randomness::java.security'
owasp:
- A02:2021 - Cryptographic Failures
cwe:
Expand Down
2 changes: 2 additions & 0 deletions java/lang/security/audit/crypto/weak-rsa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ rules:
languages: [java]
severity: WARNING
metadata:
functional-categories:
- 'crypto::search::key-length::java.security'
cwe:
- 'CWE-326: Inadequate Encryption Strength'
owasp:
Expand Down

0 comments on commit fc0871c

Please sign in to comment.