Skip to content

Java: Add XXE sink model for Woodstox WstxInputFactory#21718

Merged
owen-mc merged 2 commits intogithub:mainfrom
chmodxxx:java/woodstox-xxe
Apr 17, 2026
Merged

Java: Add XXE sink model for Woodstox WstxInputFactory#21718
owen-mc merged 2 commits intogithub:mainfrom
chmodxxx:java/woodstox-xxe

Conversation

@chmodxxx
Copy link
Copy Markdown
Contributor

@chmodxxx chmodxxx commented Apr 16, 2026

com.ctc.wstx.stax.WstxInputFactory and its abstract parent org.codehaus.stax2.XMLInputFactory2 override createXMLStreamReader, createXMLEventReader, and setProperty, so calls with those static receiver types were not matched by the existing XmlInputFactory model. Woodstox is XXE-vulnerable out of the box, so these were real false negatives in java/xxe.

@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.

Copy link
Copy Markdown
Contributor

@owen-mc owen-mc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution.

The way you've done it works fine, but I don't like the large amount of duplication. I think it would be better to make a small change to java/ql/lib/semmle/code/java/security/XmlParsers.qll by defining WstxInputFactory and replacing

      m.getDeclaringType() instanceof XmlInputFactory and

with

      (
        m.getDeclaringType() instanceof XmlInputFactory or
        m.getDeclaringType() instanceof WstxInputFactory
      ) and

Also please update the QLDoc above XmlInputFactoryStreamReader.

Comment thread java/ql/lib/change-notes/2026-04-16-woodstox-xxe.md
Salah Baddou added 2 commits April 17, 2026 18:46
`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 force-pushed the java/woodstox-xxe branch from 96d4f66 to fb2d53e Compare April 17, 2026 14:46
Copy link
Copy Markdown
Contributor

@owen-mc owen-mc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for this contribution. You did very well to create stubs and update the tests yourself.

@owen-mc owen-mc merged commit 2764580 into github:main Apr 17, 2026
21 checks passed
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