-
Notifications
You must be signed in to change notification settings - Fork 584
fix(java): treat ACCESS_EXTERNAL_DTD as an XXE sanitizer #4024
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
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,6 +113,11 @@ rules: | |
| ... | ||
|
|
||
| $FACTORY.setFeature("http://xml.org/sax/features/external-general-entities", false); | ||
| - patterns: | ||
| - pattern: $FACTORY.setAttribute($ATTR, "") | ||
| - metavariable-regex: | ||
| metavariable: $ATTR | ||
| regex: ^(.*\.)?ACCESS_EXTERNAL_DTD$ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a static factory field is hardened in a static initializer and consumed from another method, this sanitizer is in a different taint scope from Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When callers pass the factory to a local hardening helper that sets Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When code first sets Useful? React with 👍 / 👎. |
||
| - focus-metavariable: $FACTORY | ||
| - patterns: | ||
| - pattern-either: | ||
|
|
||
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.
When application code has any other expression ending in
ACCESS_EXTERNAL_DTD, this regex suppresses the XXE finding without checking what property that expression represents. For example, a localString ACCESS_EXTERNAL_DTD = XMLConstants.ACCESS_EXTERNAL_SCHEMA;followed bydbf.setAttribute(ACCESS_EXTERNAL_DTD, "")matches this sanitizer even though external DTD/entity access remains enabled. MatchXMLConstants.ACCESS_EXTERNAL_DTDexplicitly, and handle the statically imported form only when the correspondingjavax.xml.XMLConstantsstatic import is present.Useful? React with 👍 / 👎.