-
-
Notifications
You must be signed in to change notification settings - Fork 499
Skip BOM chars from XML documents #9046
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
Conversation
11c1538
to
2cc905a
Compare
SAXBuilder builder = getSAXBuilderWithPathXMLResolver(false, null); //new SAXBuilder(); | ||
builder.setFeature("http://apache.org/xml/features/validation/schema", false); | ||
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); | ||
Document jdoc = builder.build(f); |
Check failure
Code scanning / CodeQL
Resolving XML external entity in user-controlled data Critical
user-provided value
XML parsing depends on a
user-provided value
XML parsing depends on a
user-provided value
XML parsing depends on a
user-provided value
XML parsing depends on a
user-provided value
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.
@josegar74 hey, it looks like this was not introduced in the PR but already present before. Do you have an idea how to mitigate this? thank you!
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.
@jahow I see in https://codeql.github.com/codeql-query-help/java/java-xxe/ that the good example uses:
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
If it sounds fine, maybe we can create another pull request to test this properly as I am not sure if can cause side effects.
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.
@jahow I have created #9066 to solve this issue, so we can test the suggested change in https://codeql.github.com/codeql-query-help/java/java-xxe/ properly.
I've done some tests, for example using the CSW harvester and looks fine, but more testing is required.
XML documents that begin with a Byte Order Mark (BOM) cause the following exception:
This change request checks whether the XML document begins with a BOM and, if so, removes it so that the XML load works as intended.
Checklist
main
branch, backports managed with labelREADME.md
filespom.xml
dependency management. Update build documentation with intended library use and library tutorials or documentation