Skip to content

security: disable XML DTD processing in XmlPullParser to prevent XXE - #2183

Open
insaf021 wants to merge 1 commit into
googleapis:mainfrom
insaf021:security/disable-xml-dtd-processing
Open

security: disable XML DTD processing in XmlPullParser to prevent XXE#2183
insaf021 wants to merge 1 commit into
googleapis:mainfrom
insaf021:security/disable-xml-dtd-processing

Conversation

@insaf021

Copy link
Copy Markdown

Summary
Xml#createParser() did not disable FEATURE_PROCESS_DOCDECL, leaving the XmlPullParser
vulnerable to XML External Entity (XXE) injection when parsing attacker-influenced content.

Changes

  • Xml.java: set FEATURE_PROCESS_DOCDECL=false immediately after parser creation, with a
    graceful try/catch fallback for parser implementations that don't support the feature.

  • XmlTest.java: added testCreateParser_disablesDocDecl to verify DTD entity content is
    not resolved (or that the parser throws, both are safe outcomes).

  • Opened an issue before writing code

  • Tests and linter pass

  • Code coverage does not decrease

  • Docs updated

Fixes #2179 ☕️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core: XmlPullParser processes external DTD entities (XXE) — disable FEATURE_PROCESS_DOCDECL in Xml#createParser()

1 participant