Centralize XXE hardening for StAX XML parsers#12256
Open
gnodet wants to merge 1 commit into
Open
Conversation
Add XmlService.newXMLInputFactory() as a single shared method that creates a hardened XMLInputFactory with SUPPORT_DTD and IS_SUPPORTING_EXTERNAL_ENTITIES disabled. Replace all direct XMLInputFactory.newFactory() calls across the codebase with this centralized method. Also harden the Velocity templates (reader-stax.vm and reader.vm) that generate StAX readers for settings, toolchains, metadata, and plugin descriptors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8 tasks
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.
Summary
Alternative to #12251 — centralizes the XXE hardening into a single shared
XmlService.newXMLInputFactory()method instead of duplicating anewInputFactory()helper in each class.XmlService.newXMLInputFactory()that creates a hardenedXMLInputFactorywithSUPPORT_DTD=falseandIS_SUPPORTING_EXTERNAL_ENTITIES=falseXMLInputFactory.newFactory()calls across 7 source files with the centralized methodreader-stax.vm,reader.vm) that generate StAX readers for settings, toolchains, metadata, and plugin descriptors — these were missed in disable dtd and external entities in stax xml parsers #12251The maven-xinclude-extension is unaffected — it creates its own
WstxInputFactorywith entities explicitly enabled and a restrictedLocalXmlResolver.Test plan
mvn verifypasses on all affected modulesExtensionDescriptorBuilderTest.testExternalEntityIsNotResolvedconfirms XXE is blockedClaude Code on behalf of Guillaume Nodet