-
Notifications
You must be signed in to change notification settings - Fork 2k
Java: Add a query for MVEL injections #3329
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
10 commits
Select commit
Hold shift + click to select a range
c6c4c2c
Java: Add a query for MVEL injections
artem-smotrakov 32ff5ad
Java: Added CompiledExpression sink for MVEL injections
artem-smotrakov 12e0234
Java: Added CompiledAccExpression sink for MVEL injections
artem-smotrakov 6a6c805
Java: Added Accessor sink for MVEL injections
artem-smotrakov 8fd7265
Java: Added JSR 223 sinks for MVEL injections
artem-smotrakov fa717b2
Java: Added template sinks for MVEL injections
artem-smotrakov df9d10f
Java: Added MVELRuntime.execute() sink for MVEL injections
artem-smotrakov 4a83fb8
Java: Simplified MvelInjection test
artem-smotrakov 2842aee
Java: Simplified MvelInjectionLib
artem-smotrakov b7c3dd6
Java: Clean up MVEL injection query
artem-smotrakov 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
38 changes: 38 additions & 0 deletions
38
java/ql/src/experimental/Security/CWE/CWE-094/MvelInjection.qhelp
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,38 @@ | ||
| <!DOCTYPE qhelp PUBLIC "-//Semmle//qhelp//EN" "qhelp.dtd"> | ||
| <qhelp> | ||
|
|
||
| <overview> | ||
| <p> | ||
| MVEL is an expression language based on Java-syntax. | ||
| The language offers many features | ||
| including invocation of methods available in the JVM. | ||
| If a MVEL expression is built using attacker-controlled data, | ||
| and then evaluated, then it may allow the attacker to run arbitrary code. | ||
| </p> | ||
| </overview> | ||
|
|
||
| <recommendation> | ||
| <p> | ||
| Including user input in a MVEL expression should be avoided. | ||
| </p> | ||
| </recommendation> | ||
|
|
||
| <example> | ||
| <p> | ||
| The following example uses untrusted data to build a MVEL expression | ||
| and then runs it in the default powerfull context. | ||
| </p> | ||
| <sample src="UnsafeMvelExpressionEvaluation.java" /> | ||
| </example> | ||
|
|
||
| <references> | ||
| <li> | ||
| MVEL Documentation: | ||
| <a href="http://mvel.documentnode.com/">Language Guide for 2.0</a>. | ||
| </li> | ||
| <li> | ||
| OWASP: | ||
| <a href="https://owasp.org/www-community/vulnerabilities/Expression_Language_Injection">Expression Language Injection</a>. | ||
| </li> | ||
| </references> | ||
| </qhelp> | ||
19 changes: 19 additions & 0 deletions
19
java/ql/src/experimental/Security/CWE/CWE-094/MvelInjection.ql
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,19 @@ | ||
| /** | ||
| * @name Expression language injection (MVEL) | ||
| * @description Evaluation of a user-controlled MVEL expression | ||
| * may lead to remote code execution. | ||
| * @kind path-problem | ||
| * @problem.severity error | ||
| * @precision high | ||
| * @id java/mvel-expression-injection | ||
| * @tags security | ||
| * external/cwe/cwe-094 | ||
| */ | ||
|
|
||
| import java | ||
| import MvelInjectionLib | ||
| import DataFlow::PathGraph | ||
|
|
||
| from DataFlow::PathNode source, DataFlow::PathNode sink, MvelInjectionConfig conf | ||
| where conf.hasFlowPath(source, sink) | ||
| select sink.getNode(), source, sink, "MVEL injection from $@.", source.getNode(), "this user input" |
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.
Missing close tag.