-
Notifications
You must be signed in to change notification settings - Fork 9
Pull request for 10 rules ESS-ENN #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
4208c3d
insecure-biometrics-swift
ESS-ENN 2d4ea63
plaintext-http-link-html
ESS-ENN 586888d
desede-is-deprecated-java
ESS-ENN 9015c09
desede-is-deprecated-kotlin
ESS-ENN 68be70d
sizeof-this-c
ESS-ENN 3d453a8
cbc-padding-oracle-java
ESS-ENN e7b4680
no-null-cipher-java
ESS-ENN 1ba2958
rsa-no-padding-java
ESS-ENN f182a4b
changed folder position of no-null-cipher-java
ESS-ENN ac0edaa
rsa-padding-set-scala
ESS-ENN 650b88b
xmlinputfactory-dtd-enabled-scala
ESS-ENN b0c6e4e
Incorporated changes suggested by CodeRabbit Bot
ESS-ENN bd0bc1d
httponly-false-csharp
ESS-ENN 5507b0a
reqwest-accept-invalid-rust
ESS-ENN 456f431
libxml2-audit-parser-c
ESS-ENN 30f9ae3
libxml2-audit-parser-cpp
ESS-ENN 0970f4f
oracleconnectionstringbuilder-hardcoded-secret-csharp
ESS-ENN 081bad0
ecb-cipher-java
ESS-ENN bec0b7e
Changed severity for 3 rules as suggested by Bot
ESS-ENN 472fa36
use-of-weak-rsa-key-java
ESS-ENN 5fea8a2
unencrypted-socket-java
ESS-ENN a85cbfb
use-of-weak-rsa-key-kotlin
ESS-ENN 22b3dca
removing oracleconnectionstringbuilder-hardcoded-secret-csharp
ESS-ENN 090e6af
use-of-md5-digest-utils-java
ESS-ENN fc5f3a1
weak-ssl-context-java
ESS-ENN bf350e6
use-of-rc4-java
ESS-ENN 85c6f95
system-setproperty-hardcoded-secret-java
ESS-ENN 07abf42
rsa-no-padding-kotlin
ESS-ENN 126ec00
des-is-deprecated-java
ESS-ENN b62d49a
des-is-deprecated-kotlin
ESS-ENN ae12535
Made changes as per suggestions of coderabbit ai bot
ESS-ENN 1326f4c
use-of-md5-java
ESS-ENN d26328d
use-of-sha1-java
ESS-ENN 57c1edb
system-setproperty-hardcoded-secret-kotlin
ESS-ENN b679216
use-of-aes-ecb-java
ESS-ENN 6ff4438
use-of-blowfish-java
ESS-ENN 66dff6f
Update of use-of-md5-java
ESS-ENN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
id: libxml2-audit-parser-c | ||
language: c | ||
severity: warning | ||
message: >- | ||
The libxml2 library is used to parse XML. When auditing such code, make | ||
sure that either the document being parsed is trusted or that the parsing | ||
options are safe to consume untrusted documents. In such case make sure | ||
DTD or XInclude documents cannot be loaded and there is no network access. | ||
note: >- | ||
[CWE-611] Improper Restriction of XML External Entity Reference. | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A05_2021-Security_Misconfiguration | ||
rule: | ||
any: | ||
- pattern: xmlParseInNodeContext($CUR, $SRC, $DATALEN, $XML_OPTIONS, $LST) | ||
- pattern: xmlReadDoc($CUR, $SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlReadFd($FD, $SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlReadFile($SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlReadIO($IO_READ, $IO_CLOSE, $IO_CTX, $SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlReadMemory($SRC, $SIZE, $URL, $ENC, $XML_OPTIONS) | ||
- pattern: xmlCtxtReadDoc($CTX, $CUR, $SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlCtxtReadFd($CTX, $FD, $SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlCtxtReadFile($CTX, $SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlCtxtReadIO($CTX, $IO_READ, $IO_CLOSE, $IO_CTX, $SRC, $ENC,$XML_OPTIONS) | ||
- pattern: xmlCtxtReadMemory($CTX, $SRC, $SIZE, $URL, $ENC, $XML_OPTIONS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
id: sizeof-this-c | ||
language: c | ||
severity: warning | ||
message: >- | ||
Do not use `sizeof(this)` to get the number of bytes of the object in | ||
memory. It returns the size of the pointer, not the size of the object. | ||
note: >- | ||
[CWE-467]: Use of sizeof() on a Pointer Type | ||
[REFERENCES] | ||
- https://wiki.sei.cmu.edu/confluence/display/c/ARR01-C.+Do+not+apply+the+sizeof+operator+to+a+pointer+when+taking+the+size+of+an+array | ||
rule: | ||
any: | ||
- pattern: "sizeof(this)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
id: libxml2-audit-parser-cpp | ||
language: Cpp | ||
severity: warning | ||
message: >- | ||
The libxml2 library is used to parse XML. When auditing such code, make | ||
sure that either the document being parsed is trusted or that the parsing | ||
options are safe to consume untrusted documents. In such case make sure | ||
DTD or XInclude documents cannot be loaded and there is no network access. | ||
note: >- | ||
[CWE-611] Improper Restriction of XML External Entity Reference. | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A05_2021-Security_Misconfiguration | ||
rule: | ||
any: | ||
- pattern: xmlParseInNodeContext($CUR, $SRC, $DATALEN, $XML_OPTIONS, $LST) | ||
- pattern: xmlReadDoc($CUR, $SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlReadFd($FD, $SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlReadFile($SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlReadIO($IO_READ, $IO_CLOSE, $IO_CTX, $SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlReadMemory($SRC, $SIZE, $URL, $ENC, $XML_OPTIONS) | ||
- pattern: xmlCtxtReadDoc($CTX, $CUR, $SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlCtxtReadFd($CTX, $FD, $SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlCtxtReadFile($CTX, $SRC, $ENC, $XML_OPTIONS) | ||
- pattern: xmlCtxtReadIO($CTX, $IO_READ, $IO_CLOSE, $IO_CTX, $SRC, $ENC,$XML_OPTIONS) | ||
- pattern: xmlCtxtReadMemory($CTX, $SRC, $SIZE, $URL, $ENC, $XML_OPTIONS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
id: httponly-false-csharp | ||
language: csharp | ||
severity: warning | ||
message: >- | ||
"Detected a cookie where the `HttpOnly` flag is either missing or | ||
disabled. The `HttpOnly` cookie flag instructs the browser to forbid | ||
client-side JavaScript to read the cookie. If JavaScript interaction is | ||
required, you can ignore this finding. However, set the `HttpOnly` flag to | ||
`true` in all other cases. If this wasn't intentional, it's recommended to | ||
set the HttpOnly flag to true so the cookie will not be accessible through | ||
client-side scripts or to use the Cookie Policy Middleware to globally set | ||
the HttpOnly flag. You can then use the CookieOptions class when | ||
instantiating the cookie, which inherits these settings and will require | ||
future developers to have to explicitly override them on a case-by-case | ||
basis if needed. This approach ensures cookies are secure by default." | ||
note: >- | ||
[CWE-1004] Sensitive Cookie Without 'HttpOnly' Flag" | ||
[REFERENCES] | ||
- https://learn.microsoft.com/en-us/aspnet/core/security/authentication/cookie?view=aspnetcore-8.0#cookie-policy-middleware | ||
- https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.cookieoptions | ||
- https://owasp.org/Top10/A05_2021-Security_Misconfiguration | ||
rule: | ||
any: | ||
- pattern: $BUILDER.Cookie.HttpOnly = false; | ||
- pattern: $COOKIE.HttpOnly = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
id: plaintext-http-link-html | ||
language: html | ||
severity: warning | ||
message: >- | ||
"This link points to a plaintext HTTP URL. Prefer an encrypted HTTPS URL if possible." | ||
note: >- | ||
[CWE-319] Authentication Bypass by Primary Weakness | ||
[REFERENCES] | ||
- https://cwe.mitre.org/data/definitions/319.html | ||
rule: | ||
pattern: <a $$$ href=$URL>$C</a> | ||
constraints: | ||
URL: | ||
regex: ^['"`]?([Hh][Tt][Tt][Pp]://) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
id: cbc-padding-oracle-java | ||
severity: warning | ||
language: java | ||
message: >- | ||
Using CBC with PKCS5Padding is susceptible to padding oracle attacks. A | ||
malicious actor could discern the difference between plaintext with valid | ||
or invalid padding. Further, CBC mode does not include any integrity | ||
checks. Use 'AES/GCM/NoPadding' instead. | ||
note: >- | ||
[CWE-327] Use of a Broken or Risky Cryptographic Algorithm. | ||
[REFERENCES] | ||
- https://capec.mitre.org/data/definitions/463.html | ||
rule: | ||
pattern: Cipher.getInstance($MODE) | ||
constraints: | ||
MODE: | ||
regex: ".*/CBC/PKCS5Padding" |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
id: des-is-deprecated-java | ||
severity: warning | ||
language: java | ||
message: >- | ||
DES is considered deprecated. AES is the recommended cipher. Upgrade to | ||
use AES. See https://www.nist.gov/news-events/news/2005/06/nist-withdraws-outdated-data-encryption-standard | ||
for more information. | ||
note: >- | ||
[CWE-326] Inadequate Encryption Strength. | ||
[REFERENCES] | ||
- https://www.nist.gov/news-events/news/2005/06/nist-withdraws-outdated-data-encryption-standard | ||
rule: | ||
pattern: $CIPHER.getInstance($SAS) | ||
constraints: | ||
SAS: | ||
regex: "DES" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
id: desede-is-deprecated-java | ||
language: java | ||
severity: warning | ||
message: >- | ||
Triple DES (3DES or DESede) is considered deprecated. AES is the recommended cipher. Upgrade to use AES. | ||
note: >- | ||
[CWE-326]: Inadequate Encryption Strength | ||
[OWASP A03:2017]: Sensitive Data Exposure | ||
[OWASP A02:2021]: Cryptographic Failures | ||
[REFERENCES] | ||
- https://find-sec-bugs.github.io/bugs.htm#TDES_USAGE | ||
- https://csrc.nist.gov/News/2017/Update-to-Current-Use-and-Deprecation-of-TDEA | ||
rule: | ||
any: | ||
- pattern: $CIPHER.getInstance("=~/DESede.*/") | ||
- pattern: $CRYPTO.KeyGenerator.getInstance("DES") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
id: ecb-cipher-java | ||
severity: warning | ||
language: java | ||
message: >- | ||
Cipher in ECB mode is detected. ECB mode produces the same output for | ||
the same input each time which allows an attacker to intercept and replay | ||
the data. Further, ECB mode does not provide any integrity checking. See | ||
https://find-sec-bugs.github.io/bugs.htm#CIPHER_INTEGRITY. | ||
note: >- | ||
[CWE-327] Use of a Broken or Risky Cryptographic Algorithm. | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures | ||
rule: | ||
pattern: Cipher $VAR = $CIPHER.getInstance($MODE); | ||
constraints: | ||
MODE: | ||
regex: .*ECB.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
id: no-null-cipher-java | ||
severity: warning | ||
language: java | ||
message: >- | ||
NullCipher was detected. This will not encrypt anything; the cipher | ||
text will be the same as the plain text. Use a valid, secure cipher: | ||
Cipher.getInstance("AES/CBC/PKCS7PADDING"). See | ||
https://owasp.org/www-community/Using_the_Java_Cryptographic_Extensions | ||
for more information. | ||
note: >- | ||
[CWE-327] Use of a Broken or Risky Cryptographic Algorithm. | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures | ||
rule: | ||
any: | ||
- pattern: new NullCipher($$$) | ||
- pattern: new javax.crypto.NullCipher($$$) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
id: rsa-no-padding-java | ||
severity: warning | ||
language: java | ||
message: >- | ||
Using RSA without OAEP mode weakens the encryption. | ||
note: >- | ||
[CWE-326] Inadequate Encryption Strength | ||
[REFERENCES] | ||
- https://rdist.root.org/2009/10/06/why-rsa-encryption-padding-is-critical/ | ||
rule: | ||
pattern: $YST.getInstance($MODE) | ||
constraints: | ||
MODE: | ||
regex: "RSA/[Nn][Oo][Nn][Ee]/NoPadding" |
22 changes: 22 additions & 0 deletions
22
rules/java/security/system-setproperty-hardcoded-secret-java.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
id: system-setproperty-hardcoded-secret-java | ||
language: java | ||
severity: warning | ||
message: >- | ||
A secret is hard-coded in the application. Secrets stored in source | ||
code, such as credentials, identifiers, and other types of sensitive data, | ||
can be leaked and used by internal or external malicious actors. Use | ||
environment variables to securely provide credentials and other secrets or | ||
retrieve them from a secure vault or Hardware Security Module (HSM). | ||
note: >- | ||
[CWE-798]: Use of Hard-coded Credentials | ||
[OWASP A07:2021]: Identification and Authentication Failures | ||
[REFERENCES] | ||
- https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html | ||
rule: | ||
all: | ||
- any: | ||
- pattern: System.setProperty("javax.net.ssl.keyStorePassword", $PWD); | ||
- pattern: System.setProperty("javax.net.ssl.trustStorePassword", $PWD); | ||
constraints: | ||
PWD: | ||
regex: '^"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
id: unencrypted-socket-java | ||
language: java | ||
severity: info | ||
message: >- | ||
"Detected use of a Java socket that is not encrypted. As a result, the | ||
traffic could be read by an attacker intercepting the network traffic. Use | ||
an SSLSocket created by 'SSLSocketFactory' or 'SSLServerSocketFactory' | ||
instead." | ||
note: >- | ||
[CWE-319] Cleartext Transmission of Sensitive Information | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures | ||
rule: | ||
any: | ||
- pattern: new ServerSocket($$$) | ||
- pattern: new Socket($$$) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
id: use-of-aes-ecb-java | ||
language: java | ||
severity: warning | ||
message: >- | ||
Use of AES with ECB mode detected. ECB doesn't provide message | ||
confidentiality and is not semantically secure so should not be used. | ||
Instead, use a strong, secure cipher: | ||
Cipher.getInstance(\"AES/CBC/PKCS7PADDING\"). See | ||
https://owasp.org/www-community/Using_the_Java_Cryptographic_Extensions | ||
for more information. | ||
note: >- | ||
[CWE-327]: Use of a Broken or Risky Cryptographic Algorithm | ||
[OWASP A03:2017]: Sensitive Data Exposure | ||
[OWASP A02:2021]: Cryptographic Failures | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures | ||
- https://googleprojectzero.blogspot.com/2022/10/rc4-is-still-considered-harmful.html | ||
rule: | ||
pattern: $CIPHER.getInstance($MATCHES) | ||
constraints: | ||
MATCHES: | ||
regex: ".*AES/ECB/.*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
id: use-of-blowfish-java | ||
language: java | ||
severity: info | ||
message: >- | ||
Use of Blowfish was detected. Blowfish uses a 64-bit block size | ||
that makes it vulnerable to birthday attacks, and is therefore considered | ||
non-compliant. Instead, use a strong, secure cipher: | ||
Cipher.getInstance("AES/CBC/PKCS7PADDING"). See | ||
https://owasp.org/www-community/Using_the_Java_Cryptographic_Extensions | ||
for more information. | ||
note: >- | ||
[CWE-327] Use of a Broken or Risky Cryptographic Algorithm | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures | ||
- https://googleprojectzero.blogspot.com/2022/10/rc4-is-still-considered-harmful.html | ||
rule: | ||
pattern: $CIPHER.getInstance("Blowfish") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
id: use-of-md5-digest-utils-java | ||
language: java | ||
severity: warning | ||
message: >- | ||
'Detected MD5 hash algorithm which is considered insecure. MD5 is not | ||
collision resistant and is therefore not suitable as a cryptographic | ||
signature. Use HMAC instead.' | ||
note: >- | ||
[CWE-328] Use of Weak Hash | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures | ||
rule: | ||
pattern: DigestUtils.getMd5Digest($$$).digest($$$) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
id: use-of-md5-java | ||
severity: warning | ||
language: java | ||
message: >- | ||
Detected MD5 hash algorithm which is considered insecure. MD5 is not | ||
collision resistant and is therefore not suitable as a cryptographic | ||
signature. Use HMAC instead. | ||
note: >- | ||
[CWE-328] Use of Weak Hash. | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures | ||
rule: | ||
any: | ||
- pattern: java.security.MessageDigest.getInstance($ALGO) | ||
- pattern: java.security.MessageDigest.getInstance($ALGO, $$$) | ||
- pattern: MessageDigest.getInstance($ALGO) | ||
- pattern: MessageDigest.getInstance($ALGO, $$$) | ||
constraints: | ||
ALGO: | ||
regex: "MD5" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
id: use-of-rc4-java | ||
language: java | ||
severity: warning | ||
message: >- | ||
'Use of RC4 was detected. RC4 is vulnerable to several attacks, | ||
including stream cipher attacks and bit flipping attacks. Instead, use a | ||
strong, secure cipher: Cipher.getInstance("AES/CBC/PKCS7PADDING"). See | ||
https://owasp.org/www-community/Using_the_Java_Cryptographic_Extensions | ||
for more information.' | ||
note: >- | ||
[CWE-327] Use of a Broken or Risky Cryptographic Algorithm | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures | ||
- https://googleprojectzero.blogspot.com/2022/10/rc4-is-still-considered-harmful.html | ||
rule: | ||
pattern: $CIPHER.getInstance("RC4") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
id: use-of-sha1-java | ||
language: java | ||
severity: warning | ||
message: >- | ||
Detected SHA1 hash algorithm which is considered insecure. SHA1 is not | ||
collision resistant and is therefore not suitable as a cryptographic | ||
signature. Instead, use PBKDF2 for password hashing or SHA256 or SHA512 | ||
for other hash function applications. | ||
note: >- | ||
[CWE-328] Use of Weak Hash. | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures | ||
rule: | ||
any: | ||
- pattern: $DU.getSha1Digest().digest($$$) | ||
- pattern: MessageDigest.getInstance($ALGO) | ||
- pattern: java.security.MessageDigest.getInstance($ALGO,$$$) | ||
constraints: | ||
ALGO: | ||
regex: "SHA1|SHA-1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
id: use-of-weak-rsa-key-java | ||
language: java | ||
severity: warning | ||
message: >- | ||
RSA keys should be at least 2048 bits based on NIST recommendation. | ||
note: >- | ||
[CWE-326] Inadequate Encryption Strength. | ||
[REFERENCES] | ||
- https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html#algorithms | ||
rule: | ||
pattern: | | ||
$KEY.initialize($AST) | ||
follows: KeyPairGenerator $KEY = $G.getInstance("RSA"); | ||
constraints: | ||
AST: | ||
regex: '^(-?(0|[1-9][0-9]?|[1-9][0-9]{2}|1[0-9]{3}|20[0-3][0-9]|204[0-7])(\.[0-9]+)?|0|-[1-9][0-9]*|-[1-9][0-9]{2,}|-1[0-9]{3}|-20[0-3][0-9]|-204[0-7])$' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refine rule patterns to accurately target deprecated usage.
The first pattern is well-targeted and should effectively catch instances of DESede usage. However, the second pattern might inadvertently flag all DES usages, not just DESede. This could lead to false positives since DES and DESede are related but distinct.
Consider refining the second pattern to specifically include "DESede" to avoid broad matches that could affect the accuracy of the rule.
Suggested change for the second pattern:
This change ensures that the pattern only flags the deprecated DESede usage, aligning it with the intent of the rule.
Committable suggestion