Skip to content

Java: Add XXE sink model for Woodstox WstxInputFactory#21718

Open
chmodxxx wants to merge 1 commit intogithub:mainfrom
chmodxxx:java/woodstox-xxe
Open

Java: Add XXE sink model for Woodstox WstxInputFactory#21718
chmodxxx wants to merge 1 commit intogithub:mainfrom
chmodxxx:java/woodstox-xxe

Conversation

@chmodxxx
Copy link
Copy Markdown
Contributor

com.ctc.wstx.stax.WstxInputFactory overrides createXMLStreamReader, createXMLEventReader and setProperty from XMLInputFactory, so the existing XmlInputFactory model in XmlParsers.qll does not match calls where the static receiver type is WstxInputFactory (or its supertype org.codehaus.stax2.XMLInputFactory2). Woodstox is vulnerable to XXE in its default configuration, so these missed sinks were false negatives in java/xxe.

This adds a scoped framework model under
semmle/code/java/frameworks/woodstox/WoodstoxXml.qll (registered in the Frameworks module of XmlParsers.qll) that recognises these calls as XXE sinks and treats the factory as safe when both javax.xml.stream.supportDTD and
javax.xml.stream.isSupportingExternalEntities are disabled — mirroring the existing XMLInputFactory safe-configuration logic.

`com.ctc.wstx.stax.WstxInputFactory` overrides `createXMLStreamReader`,
`createXMLEventReader` and `setProperty` from `XMLInputFactory`, so the
existing `XmlInputFactory` model in `XmlParsers.qll` does not match calls
where the static receiver type is `WstxInputFactory` (or its supertype
`org.codehaus.stax2.XMLInputFactory2`). Woodstox is vulnerable to XXE in
its default configuration, so these missed sinks were false negatives in
`java/xxe`.

This adds a scoped framework model under
`semmle/code/java/frameworks/woodstox/WoodstoxXml.qll` (registered in the
`Frameworks` module of `XmlParsers.qll`) that recognises these calls as
XXE sinks and treats the factory as safe when both
`javax.xml.stream.supportDTD` and
`javax.xml.stream.isSupportingExternalEntities` are disabled — mirroring
the existing `XMLInputFactory` safe-configuration logic.
@chmodxxx chmodxxx requested a review from a team as a code owner April 16, 2026 04:18
@owen-mc
Copy link
Copy Markdown
Contributor

owen-mc commented Apr 16, 2026

Thanks for this contribution. I've started CI. Just to be clear, the logic is exactly the same as XmlInputFactory, except that m.getDeclaringType() is different, right?

@chmodxxx
Copy link
Copy Markdown
Contributor Author

Hey, thanks for looking. Yes indeed, I didn't want to mess with the core QLL getDeclaringType and figured a sub parser logic would be better.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants