Skip to content

harden SOAPPart.setContent xml parser against xxe#1221

Open
digi-scrypt wants to merge 1 commit into
apache:masterfrom
digi-scrypt:saaj-soappart-xxe
Open

harden SOAPPart.setContent xml parser against xxe#1221
digi-scrypt wants to merge 1 commit into
apache:masterfrom
digi-scrypt:saaj-soappart-xxe

Conversation

@digi-scrypt

Copy link
Copy Markdown
  1. SOAPPartImpl.setContent builds its XMLInputFactory with newInstance() and no other settings, so DTDs and external entities are left on.
  2. when the Source is a StreamSource it's handed straight to that reader, so a body with a DOCTYPE + SYSTEM entity gets expanded — file:// reads or outbound URLs from the parser.

Set SUPPORT_DTD and IS_SUPPORTING_EXTERNAL_ENTITIES to false on the factory before it parses.

What happens if someone calls setContent with a StreamSource over an inbound stream? That's the documented SAAJ way to load a body, so the bytes are attacker reachable and the hardening has to live here rather than in the caller. Lines up with the recent WSDL/XSD XXE work that hardened the DOM path but didn't touch this StAX one. Added a SOAPPartTest case that points an external entity at a temp file and checks the contents never land in the message.

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.

1 participant