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 XXE sinks by haby0 · Pull Request #6564 · github/codeql

Conversation

@haby0

@haby0 haby0 commented Aug 27, 2021

Copy link
Copy Markdown
Contributor

There are many XML parsers for Java, and most of them are vulnerable to XXE because their default settings enable parsing of
external entities. This query currently identifies vulnerable XML parsing from the following parsers: javax.xml.validation.Validator,
org.dom4j.DocumentHelper, org.apache.commons.digester3.Digester, java.beans.XMLDecoder, org.rundeck.api.parser.ParserHelper, org.apache.commons.digester.Digester, org.apache.tomcat.util.digester.Digester

Open source components: vertx-web

Sorry, something went wrong.

Uh oh!

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

All reactions
@haby0
haby0 requested a review from a team as a code owner August 27, 2021 14:19
@github-actions github-actions Bot added documentation Java labels Aug 27, 2021
This was referenced Aug 27, 2021
[Java]: Add XXE sinks github/securitylab#420
Closed
[Java]: Add XXE sinks github/securitylab#426
Closed
@smowton

smowton commented Sep 2, 2021

Copy link
Copy Markdown
Contributor

This PR is currently a big rebase and merge mess -- recommend flattening unnecessary commits to make reviewing this easier.

All reactions

Sorry, something went wrong.

Uh oh!

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

smowton
smowton reviewed Sep 7, 2021
View reviewed changes
Comment thread java/ql/src/experimental/Security/CWE/CWE-611/XXE.ql Outdated
* @kind path-problem
* @problem.severity error
* @precision high
* @id java/xxe

@smowton smowton Sep 7, 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.

Suggested change
* @id java/xxe
* @id java/xxe-with-experimental-sinks

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-611/XXE.ql Outdated
@@ -0,0 +1,31 @@
/**
* @name Resolving XML external entity in user-controlled data

@smowton smowton Sep 7, 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.

Suggested change
* @name Resolving XML external entity in user-controlled data
* @name Resolving XML external entity in user-controlled data (experimental sinks)

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-611/XXE.ql
Comment on lines +3 to +4
* @description Parsing user-controlled XML documents and allowing expansion of external entity
* references may lead to disclosure of confidential data or denial of service.

@smowton smowton Sep 7, 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.

Suggested change
* @description Parsing user-controlled XML documents and allowing expansion of external entity
* references may lead to disclosure of confidential data or denial of service.
* @description Parsing user-controlled XML documents and allowing expansion of external entity
* references may lead to disclosure of confidential data or denial of service.
* (note this version differs from query `java/xxe` by including support for additional possibly-vulnerable XML parsers)

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-611/XXELib.qll Outdated
}

/**
* The classes `org.apache.commons.digester3.Digester` or `org.apache.commons.digester.Digester` or `org.apache.tomcat.util.digester.Digester`.

@smowton smowton Sep 7, 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.

Suggested change
* The classes `org.apache.commons.digester3.Digester` or `org.apache.commons.digester.Digester` or `org.apache.tomcat.util.digester.Digester`.
* The classes `org.apache.commons.digester3.Digester`, `org.apache.commons.digester.Digester` or `org.apache.tomcat.util.digester.Digester`.

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-611/XXELocal.ql Outdated
@@ -0,0 +1,29 @@
/**
* @name Resolving XML external entity in local source

@smowton smowton Sep 7, 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.

Is there any reason to add this version? Did you need it to catch some CVE? If not, drop the local version.

Sorry, something went wrong.

Uh oh!

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

All reactions

@haby0 haby0 Sep 7, 2021

Copy link
Copy Markdown
Contributor Author

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.

Yes i am using it to catch some cve.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread java/ql/lib/semmle/code/java/security/XmlParsers.qll Outdated
this.getMethod() = m and
m.getDeclaringType().hasQualifiedName("javax.xml.transform.sax", "SAXTransformerFactory") and
m.hasName("newXMLFilter")
m.getName() in ["newXMLFilter", "newTransformerHandler"]

@smowton smowton Sep 7, 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.

Move this change to the experimental query

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread java/ql/lib/semmle/code/java/security/XmlParsers.qll Outdated

/** An expression that always has the same string value. */
private class ConstantStringExpr extends Expr {
class ConstantStringExpr extends Expr {

@smowton smowton Sep 7, 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.

Copy this to your qll file rather than expose it: the heuristic is bad enough that we probably don't want to publicly expose this difficult-to-explain partial solution.

Sorry, something went wrong.

Uh oh!

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

All reactions
@haby0
haby0 requested review from smowton and removed request for a team September 7, 2021 10:24
smowton
smowton reviewed Sep 7, 2021
View reviewed changes
Comment thread java/ql/lib/semmle/code/java/security/XmlParsers.qll
}

/*
* SAXTransformer: https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#saxtransformerfactory

@smowton smowton Sep 7, 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.

Undo this change: this file should be unchanged except exposing SafeTransformerFactoryFlowConfig which is acceptable, then the experimental query should add the extra sink.

Sorry, something went wrong.

Uh oh!

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

All reactions
@haby0
haby0 requested a review from smowton September 8, 2021 01:14
smowton
smowton reviewed Sep 10, 2021
View reviewed changes
Comment thread java/ql/src/experimental/Security/CWE/CWE-611/XXELocal.ql Resolved

Uh oh!

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

smowton added 2 commits September 10, 2021 13:49
@smowton
Add experimental variants of java/xxe, incorporating new sinks and …
2d03840
…a version that uses local sources.

Originally authored by @haby0, squashed to clean up a tangled commit history.
@smowton
Update test expectations to account for dataflow subpaths changes
29028c5
smowton
smowton approved these changes Sep 10, 2021
View reviewed changes
@smowton
smowton merged commit 0ebbb33 into github:main Sep 10, 2021
@haby0
haby0 deleted the java/xxe/new branch September 15, 2021 01:49
@atorralba atorralba mentioned this pull request Apr 26, 2023
Java: Promote experimental XXE sinks #12932
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@smowton smowton smowton approved these changes
Reviewers whose approvals may not affect merge requirements

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.

2 participants

@haby0 @smowton
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.