GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Java : Add SSTI query · Pull Request #5935 · github/codeql

Conversation

@ghost

@ghost ghost commented May 20, 2021

Copy link
Copy Markdown

This adds a query to detect server side template injections in Java.

This is a continuation of #3353. Since, that one is quite stale, I am closing that and opening a new one .

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ghost
ghost self-requested a review as a code owner May 20, 2021 20:41
@github-actions github-actions Bot added the Java label May 20, 2021
@ghost ghost mentioned this pull request May 20, 2021
[WIP] Java : Add support for detecting Template Injections in Java. #3353
Closed
smowton
smowton reviewed May 21, 2021
View reviewed changes
Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/semmle/code/java/frameworks/FreeMarker.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/semmle/code/java/frameworks/JinJava.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/semmle/code/java/frameworks/Velocity.qll Outdated
}

/** Models `attachEventCartridge` method of Velocity Templating Engine. */
class MethodVelocityAttachEventCartridge extends Method {

@smowton smowton May 21, 2021

Copy link
Copy Markdown
Contributor

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.

Unused?

Check other class/method defns to see if they're still used.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@intrigus-lgtm intrigus-lgtm mentioned this pull request Jul 19, 2021
Java: Introduce Freemarker for SSTI queries #6320
Open
@smowton

smowton commented Jul 19, 2021

Copy link
Copy Markdown
Contributor

I'd completely lost track of this; are you applying to the bounty program for this PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost
ghost dismissed a stale review via 97357c0 July 19, 2021 14:34
@ghost

ghost commented Jul 19, 2021

Copy link
Copy Markdown
Author

@smowton I am sorry for the delay in addressing the review. There is already an issue open github/securitylab#94 for this PR. I can see the bot has marked that as closed but on Github it is reflected as open. You may want to check what happening here. The PR push should have triggered the issue open.

Anyways, I have now made some changes. The PR is now ready for review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

smowton
smowton reviewed Jul 20, 2021
View reviewed changes
Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

@smowton

smowton commented Jul 20, 2021

Copy link
Copy Markdown
Contributor

@porcupineyhairs please create a fresh bounty application for this

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost ghost mentioned this pull request Jul 21, 2021
Java : Add query to detect Server Side Template Injection (SSTI) github/securitylab#410
Closed
@ghost

ghost commented Nov 10, 2021

Copy link
Copy Markdown
Author

@smowton Any updates here?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@smowton

smowton commented Nov 10, 2021

Copy link
Copy Markdown
Contributor

This is under review by the security lab; comments should be directed to github/securitylab#410 about that. The CodeQL team will review as and when it passes their review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@smowton
smowton requested a review from atorralba November 17, 2021 17:19
atorralba
atorralba reviewed Nov 22, 2021
View reviewed changes

@atorralba atorralba left a comment

Copy link
Copy Markdown
Contributor

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.

I added some inline comments. Also, I made a commit with a trivial change (added this. to some predicate calls).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/semmle/code/java/frameworks/Velocity.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/semmle/code/java/frameworks/Velocity.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

smowton
smowton reviewed Nov 22, 2021
View reviewed changes

@smowton smowton left a comment

Copy link
Copy Markdown
Contributor

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.

Currently lacks tests: please add test cases to java/ql/test/experimental/query-tests/security/CWE-094, as well as stubs of your dependencies to https://github.com/github/codeql/tree/main/java/ql/test/experimental/stubs

There are many examples at https://github.com/github/codeql/tree/main/java/ql/test/experimental/query-tests/security to crib off, but do ask if you have any questions about writing codeql tests.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/semmle/code/java/frameworks/FreeMarker.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/semmle/code/java/frameworks/JinJava.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/semmle/code/java/frameworks/FreeMarker.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

smowton
smowton reviewed Dec 15, 2021
View reviewed changes
Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the documentation label Feb 5, 2022
@ghost

ghost commented Feb 20, 2022

Copy link
Copy Markdown
Author

@smowton Sorry for the long wait. I have added the necessary tests and a qhelp. This PR is now ready for a review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

smowton
smowton reviewed Feb 21, 2022
View reviewed changes
Comment thread java/ql/src/Security/CWE/CWE-094/SSTIBad.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/Security/CWE/CWE-094/TemplateInjection.qhelp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/Security/CWE/CWE-094/TemplateInjection.qhelp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/Security/CWE/CWE-094/TemplateInjection.qhelp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/Security/CWE/CWE-094/TemplateInjection.qhelp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/Security/CWE/CWE-094/TemplateInjection.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

@smowton

smowton commented Feb 21, 2022

Copy link
Copy Markdown
Contributor

Why is this being added direct to the main query suite rather than experimental? (for experimental additions you won't need a change note either)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost

ghost commented Feb 22, 2022

Copy link
Copy Markdown
Author

@smowton I moved it from experimental to stable as this meets all the requirements for a supported stable query as listed here. The PR includes a well documented query along with units tests, and a qhelp. The only divergence from the norm is that I include all of these in a single PR instead of two separate ones.

Do you want me to split this one into two parts?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@smowton

smowton commented Feb 22, 2022

Copy link
Copy Markdown
Contributor

@porcupineyhairs to enter the main query suite we'll want to do a more detailed study into false positives and ways they could be remediated. Please commit this to the experimental area for the time being.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost

ghost commented Feb 22, 2022

Copy link
Copy Markdown
Author

@smowton Changes done! PTAL.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Porcuiney Hairs
Java : Add SSTI query
e536628
@smowton

smowton commented Feb 22, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  File "ql/java/ql/test/experimental/query-tests/security/CWE-094/JinJavaSSTI.java" contains a non-ASCII character at the location marked with `|` in:
  tring, Object> context = new HashMap<>();
  		// String render|
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@smowton

smowton commented Feb 22, 2022

Copy link
Copy Markdown
Contributor
[2022-02-22 15:31:28] This is codeql generate query-help -vvv --log-to-stderr --output out --format markdown --search-path . -- ql/java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qhelp
  Error: 2-22 15:31:29] [ERROR] generate query-help> ql/java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qhelp: Could not find sample SSTIBad.py
  Error: 2-22 15:31:29] [ERROR] generate query-help> ql/java/ql/src/experimental/Security/CWE/CWE-094/TemplateInjection.qhelp: Could not find sample SSTIGood.py
  [2022-02-22 15:31:29] Exception caught at top level: 1 qhelp files could not be processed.
                        com.semmle.cli2.generate.QueryHelpCommand.executeSubcommand(QueryHelpCommand.java:205)
                        com.semmle.cli2.picocli.SubcommandCommon.call(SubcommandCommon.java:500)
                        com.semmle.cli2.picocli.SubcommandMaker.runMain(SubcommandMaker.java:205)
                        com.semmle.cli2.picocli.SubcommandMaker.runMain(SubcommandMaker.java:214)
                        com.semmle.cli2.CodeQL.main(CodeQL.java:98)
  A fatal error occurred: 1 qhelp files could not be processed.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Porcupiney Hairs
Include suggestions from review
c81d85f
@ghost

ghost commented Feb 22, 2022

Copy link
Copy Markdown
Author

@smowton Done!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@smowton
Replace more non-breaking spaces
476997a
smowton added 3 commits February 23, 2022 11:41
@smowton
Autoformat
50d9945
@smowton
Java template injection query: import pathgraph
a8fe10f
@smowton
Note path query expectations
7b425a8
smowton
smowton approved these changes Feb 23, 2022
View reviewed changes
@smowton
smowton merged commit 01db73b into github:main Feb 23, 2022
@atorralba atorralba mentioned this pull request Sep 8, 2022
Java: Promote Server-side template injection from experimental #10352
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

documentation Java

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@smowton @atorralba @intrigus-lgtm
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.