Skip to content

Disable external entity resolution in MSV schema factories - #320

Open
aizu-m wants to merge 5 commits into
FasterXML:mainfrom
aizu-m:msv-external-entities
Open

Disable external entity resolution in MSV schema factories#320
aizu-m wants to merge 5 commits into
FasterXML:mainfrom
aizu-m:msv-external-entities

Conversation

@aizu-m

@aizu-m aizu-m commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Reproducer output against main, schema documents carrying external entities:

W3C  : validates <InjectedByExternalEntity/> ? true       <!ENTITY % ext SYSTEM 'file:...'>  %ext;
RNG  : validates <root>LeakedFromLocalFile</root> ? true  <!ENTITY xxe SYSTEM 'file:...'>  <value>&xxe;</value>

Noticed while grepping the tree for SAXParserFactory.newInstance(). Both MSV construction sites apply only setNamespaceAware(true), so entities in a schema document get resolved: BaseSchemaFactory.getSaxFactory(), shared by the W3C and RELAX NG factories, and the W3CMultiSchemaFactory constructor. The RELAX NG case copies the referenced file into the grammar verbatim. The W3C case pulls declarations out of a fetched DTD and applies them.

Neither the Stax2 factory API nor MSV hands the SAX parser back, so a caller has no way to switch this off. That is why the fix sits at the two construction sites.

xs:include / xs:import and externalRef are resolved by MSV itself rather than through entity resolution, so those keep working. Entities declared in an internal subset, and schemas with no DOCTYPE at all, behave as before. Test covers both directions.

@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 71.16% 📈 +0.070%
Branches branches 62.40% 📈 +0.030%

Coverage data generated from JaCoCo test results

@cowtowncoder cowtowncoder added this to the 7.2.0 milestone Aug 3, 2026
@cowtowncoder cowtowncoder changed the title disable external entity resolution in MSV schema factories Disable external entity resolution in MSV schema factories Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 71.40% 📈 +0.060%
Branches branches 62.89% 📈 +0.020%

Coverage data generated from JaCoCo test results

@cowtowncoder cowtowncoder modified the milestones: 7.2.0, 7.2.2 Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 71.42% 📈 +0.080%
Branches branches 62.91% 📈 +0.040%

Coverage data generated from JaCoCo test results

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 71.64% 📈 +0.300%
Branches branches 63.03% 📈 +0.160%

Coverage data generated from JaCoCo test results

@cowtowncoder

Copy link
Copy Markdown
Member

This probably needs to go in 7.3.0 since it may break legitimate use.

@cowtowncoder cowtowncoder modified the milestones: 7.2.2, 7.3., 7.3.0 Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 71.62% 📈 +0.280%
Branches branches 63.00% 📈 +0.130%

Coverage data generated from JaCoCo test results

@aizu-m

aizu-m commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Agreed, 7.3.0 is the right place. Any schema document that relies on pulling entities from an external file would stop loading with this in, so it shouldn't ride along in a patch release. Saw you moved the notes over already.

@aizu-m

aizu-m commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

any update?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants