-
Notifications
You must be signed in to change notification settings - Fork 6
Add security rules for RSA encryption, XML processing, and AES secrets #81
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
Closed
Closed
Changes from all commits
Commits
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,17 @@ | ||
id: rsa-padding-set-scala | ||
language: scala | ||
severity: warning | ||
message: >- | ||
Usage of RSA without OAEP (Optimal Asymmetric Encryption Padding) may | ||
weaken encryption. This could lead to sensitive data exposure. Instead, | ||
use RSA with `OAEPWithMD5AndMGF1Padding` instead. | ||
note: >- | ||
[CWE-780] Use of RSA Algorithm without OAEP | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures | ||
rule: | ||
any: | ||
- pattern: $CIPHER.getInstance($MODE) | ||
constraints: | ||
MODE: | ||
regex: '.*RSA/.*/NoPadding.*' | ||
ESS-ENN marked this conversation as resolved.
Show resolved
Hide resolved
|
172 changes: 172 additions & 0 deletions
172
rules/scala/security/xmlinputfactory-dtd-enabled-scala.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,172 @@ | ||
id: xmlinputfactory-dtd-enabled-scala | ||
language: scala | ||
severity: warning | ||
message: >- | ||
XMLInputFactory being instantiated without calling the setProperty | ||
functions that are generally used for disabling entity processing. User | ||
controlled data in XML Document builder can result in XML Internal Entity | ||
Processing vulnerabilities like the disclosure of confidential data, | ||
denial of service, Server Side Request Forgery (SSRF), port scanning. Make | ||
sure to disable entity processing functionality. | ||
note: >- | ||
[CWE-611] Improper Restriction of XML External Entity. | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A05_2021-Security_Misconfiguration | ||
utils: | ||
match_pattern_ new_XMLInputFactory_newFactory_&_newInstance: | ||
kind: call_expression | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: field_expression | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: identifier | ||
regex: '^XMLInputFactory$' | ||
- has: | ||
stopBy: end | ||
kind: identifier | ||
regex: '^newFactory|newInstance$' | ||
- has: | ||
stopBy: end | ||
kind: arguments | ||
- inside: | ||
stopBy: end | ||
kind: val_definition | ||
all: | ||
- not: | ||
follows: | ||
stopBy: end | ||
kind: call_expression | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: field_expression | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: identifier | ||
- has: | ||
stopBy: end | ||
kind: identifier | ||
regex: '^setProperty$' | ||
- has: | ||
stopBy: end | ||
kind: arguments | ||
all: | ||
- has: | ||
stopBy: neighbor | ||
kind: string | ||
regex: ^"javax.xml.stream.isSupportingExternalEntities"$ | ||
- has: | ||
stopBy: neighbor | ||
kind: boolean_literal | ||
regex: '^false$' | ||
|
||
- not: | ||
precedes: | ||
stopBy: end | ||
kind: call_expression | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: field_expression | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: identifier | ||
- has: | ||
stopBy: end | ||
kind: identifier | ||
regex: '^setProperty$' | ||
- has: | ||
stopBy: end | ||
kind: arguments | ||
all: | ||
- has: | ||
stopBy: neighbor | ||
kind: string | ||
regex: ^"javax.xml.stream.isSupportingExternalEntities"$ | ||
- has: | ||
stopBy: neighbor | ||
kind: boolean_literal | ||
regex: '^false$' | ||
|
||
match_pattern_new_XMLInputFactory: | ||
kind: call_expression | ||
all: | ||
- has: | ||
stopBy: neighbor | ||
kind: identifier | ||
regex: '^XMLInputFactory$' | ||
- has: | ||
stopBy: neighbor | ||
kind: arguments | ||
- inside: | ||
stopBy: end | ||
kind: val_definition | ||
all: | ||
- not: | ||
follows: | ||
stopBy: end | ||
kind: call_expression | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: field_expression | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: identifier | ||
- has: | ||
stopBy: end | ||
kind: identifier | ||
regex: '^setProperty$' | ||
- has: | ||
stopBy: end | ||
kind: arguments | ||
all: | ||
- has: | ||
stopBy: neighbor | ||
kind: string | ||
regex: ^"javax.xml.stream.isSupportingExternalEntities"$ | ||
- has: | ||
stopBy: neighbor | ||
kind: boolean_literal | ||
regex: '^false$' | ||
|
||
- not: | ||
precedes: | ||
stopBy: end | ||
kind: call_expression | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: field_expression | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: identifier | ||
- has: | ||
stopBy: end | ||
kind: identifier | ||
regex: '^setProperty$' | ||
- has: | ||
stopBy: end | ||
kind: arguments | ||
all: | ||
- has: | ||
stopBy: neighbor | ||
kind: string | ||
regex: ^"javax.xml.stream.isSupportingExternalEntities"$ | ||
- has: | ||
stopBy: neighbor | ||
kind: boolean_literal | ||
regex: '^false$' | ||
|
||
rule: | ||
kind: call_expression | ||
any: | ||
- matches: match_pattern_ new_XMLInputFactory_newFactory_&_newInstance | ||
- matches: match_pattern_new_XMLInputFactory |
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.
Uh oh!
There was an error while loading. Please reload this page.