Skip to content

Java: Promote MVEL injection query from experimental - #6001

Merged
aschackmull merged 15 commits into
github:mainfrom
atorralba:atorralba/promote-mvel-injection
Aug 2, 2021
Merged

Java: Promote MVEL injection query from experimental#6001
aschackmull merged 15 commits into
github:mainfrom
atorralba:atorralba/promote-mvel-injection

Conversation

@atorralba

@atorralba atorralba commented Jun 3, 2021

Copy link
Copy Markdown
Contributor

PR to promote the MVEL Injection query created in #3329

Changes

  • Existing files were moved out of experimental.
  • The MvelInjectionLib.qll file was renamed to MvelInjection.qll and refactored to use the CSV sink model.
  • Refactored tests to use InlineExpectationsTest.

Evaluation

With the addition of the JsonParser taint step introduced in the promotion of the OGNL injection query, this query now detects CVE-2020-13942 (Remote Code Execution in Apache Unomi). This vulnerability was fixed with a filter that implements a deny-list of methods that can be called from MVEL, so the query will still report the issue even though Unomi is no longer vulnerable. Nonetheless, I tried adding that filter as a sanitizer and the query then correctly reports no issues, but it's such a specific sanitizer that I considered it wasn't worth to add it.

@atorralba
atorralba requested a review from a team as a code owner June 3, 2021 10:17
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged. The differences can be found in the comparison artifact of this workflow run.

@aschackmull aschackmull left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like some reshuffling of the content of the two files MvelInjectionQuery.qll and MvelInjectionSinkModels.qll. Only the configuration should go in MvelInjectionQuery.qll whereas the rest of it should go in a file called MvelInjection.qll, which can then both expose the extension points and be generally importable without leaking the configuration.

The qhelp also needs doc review.

@atorralba

atorralba commented Jul 19, 2021

Copy link
Copy Markdown
Contributor Author

I'd like some reshuffling of the content of the two files MvelInjectionQuery.qll and MvelInjectionSinkModels.qll. Only the configuration should go in MvelInjectionQuery.qll whereas the rest of it should go in a file called MvelInjection.qll, which can then both expose the extension points and be generally importable without leaking the configuration.

I was following the pattern applied to JEXL Injection in all my open PRs:

Should that be changed everywhere to *Query.qll containing only the configuration, and *.qll (instead of *SinkModels.qll) containing everything else and being imported in ExternalFlow.qll? See 70081b6 to check if it fits the expectations.

There are also some queries that use a secondary data flow configuration (e.g. DataFlow2). With these changes, should those be made public and moved to *Query.qll too?

@aschackmull

Copy link
Copy Markdown
Contributor

There is some potential merit in keeping the sink models separate such that ExternalFlow doesn't need to import a lot of unrelated things - if we do that then we likely need 3 supporting qll files rather than 2, since all the extension points for the query shouldn't be in *Query.qll, but rather in something more generally importable. But I think the structure I outlined and which is current in this PR is also fine. Splitting the sinks into a third file doesn't really make much difference (the only potential difference might be compilation time). So yeah, the JEXL example should be refactored as well - we don't want the query extension points in a *Query.qll file. @smowton what do you think? Do you have a preference for 2 or 3 supporting qll files for this case?

Comment thread java/ql/src/semmle/code/java/security/MvelInjection.qll Outdated
Comment thread java/ql/src/semmle/code/java/security/MvelInjection.qll Outdated
Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
@aschackmull aschackmull added the ready-for-doc-review This PR requires and is ready for review from the GitHub docs team. label Jul 20, 2021

@aschackmull aschackmull left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but needs docs review of the qhelp as this wasn't done when it was originally merged to experimental.

mchammer01
mchammer01 previously approved these changes Jul 29, 2021

@mchammer01 mchammer01 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atorralba - this is looking good to me ✨
I made a few minor tweaks to the qhelp file and noticed powerfull on line 23. Not sure whether this is a typo or a genuine context name, so left it as is for now.
Hope this helps!

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged. The differences can be found in the comparison artifact of this workflow run.

@atorralba

Copy link
Copy Markdown
Contributor Author

@atorralba - this is looking good to me ✨
I made a few minor tweaks to the qhelp file and noticed powerfull on line 23. Not sure whether this is a typo or a genuine context name, so left it as is for now.
Hope this helps!

Thank you for the review! It was a typo indeed. I removed the word altogether since it wasn't too relevant, and added a "GOOD" example to the sample Java code.

@artem-smotrakov artem-smotrakov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am glad to see the query is going to be added to the main query pack!

@aschackmull
aschackmull merged commit 53e6ddf into github:main Aug 2, 2021
@atorralba
atorralba deleted the atorralba/promote-mvel-injection branch August 2, 2021 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Java ready-for-doc-review This PR requires and is ready for review from the GitHub docs team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants