feat(java): detect unhardened DocumentBuilderFactory/TransformerFactory XML parsing (CWE-611) - #118
Open
ai-anant wants to merge 1 commit into
Open
feat(java): detect unhardened DocumentBuilderFactory/TransformerFactory XML parsing (CWE-611)#118ai-anant wants to merge 1 commit into
ai-anant wants to merge 1 commit into
Conversation
…ry XML parsing (CWE-611)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds Jenkins-oriented Java rules for XML External Entity (XXE) processing:
codevigilant.java.jenkins.xxe.documentbuilderfactory-disallow-doctype-decl-missingFires when
DocumentBuilderFactoryis used to parse XML (newDocumentBuilder()/newDocumentBuilder().parse(...)) without first disabling DOCTYPE declarations(
setFeature("http://apache.org/xml/features/disallow-doctype-decl", true)) orexternal entities (
external-general-entities/external-parameter-entities).codevigilant.java.jenkins.xxe.transformerfactory-dtds-not-disabledFires when
TransformerFactory.newTransformer()is called without restrictingexternal DTD access (
setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "")/ACCESS_EXTERNAL_STYLESHEET).Why it matters: in Jenkins plugins these factories frequently parse XML derived from
network/service responses (SCM server output, webhook bodies, uploaded reports).
A malicious or compromised upstream service can inject a DOCTYPE with external
entities, giving the attacker a file-read / SSRF primitive in the Jenkins controller
JVM. The rules use
pattern-not-insideonsetFeature(...)/setAttribute(...)so hardened factories are not flagged.
Validated with
semgrep --validate; tested against a positive repro (unhardenedfactories parsing a file - both rules fire) and a hardened negative (setFeature /
setAttribute present - no findings).