XML parsers you did not configure
A dependency can parse XML with its own defaults even when your code’s parser is hardened. The endpoint that accepts the bytes is still yours.
Diagram
From your route to a parser inside a library
Step 1 of 4
Route
Your handler accepts a body or a file and hands the bytes to a library.
# A route receives a document body. # A library later in the stack may parse it.
Flags are set on the parser you construct.
It builds a second parser.
Untrusted XML reaches the second one.
The example on the open step is one illustration, or the fix you can paste into an application you own.
What this page is made of
4 pieces. Each one says what fails, who is affected, what you would notice, and what you change.
Two parsers, one body
- What fails
- Hardening the parser you call does nothing for the parser a library calls on the same bytes.
- Who is affected
- Owners of files or internal services that second parser can reach.
- What you would notice
- A dependency that mentions XML in its tree, on a route that accepts uploads or SOAP.
- What you change
- Find every parser. Configure it or remove the route’s ability to reach it.
Defaults change across versions
- What fails
- A safe default in the version you read about may not be the version you pin. The pin and the test are the record.
- Who is affected
- The next upgrade that silently swaps defaults.
- What you would notice
- A lockfile bump with no XML test in the suite.
- What you change
- Pin the parser. Keep a test that a document type fails on every endpoint that accepts XML.
An edge filter is not a parser
- What fails
- Rejecting a string in the body is a seatbelt. Encodings and nested documents get past string checks. The parser flags still have to be set.
- Who is affected
- Anyone a bypassed filter can reach through the real parser.
- What you would notice
- A ticket that closes the issue because the route searches for a document-type token.
- What you change
- Keep the parser configuration. Treat the string check as extra, not as the fix.
Where XML hides
- What fails
- SAML, SOAP, RSS, SVG, office previews, and “XML config import” are the routes. So are bill-of-materials and license files if you parse them on upload.
- Who is affected
- The operator who imported a file, and the owners of anything the parser can read.
- What you would notice
- An inventory of XML routes that lists one and misses the SSO callback.
- What you change
- Make the inventory part of review. New XML acceptance has to use the helper.
Your settings do not cross a library boundary
Application code often gets XML right in the one factory the team wrote, then calls a client library that parses a status document, a SAML response, or an office manifest on its own. That library constructs a parser you have never seen, with the defaults of the year it was written. The bytes are the same untrusted bytes.
Treat “we disabled entities” as a claim about a specific object in memory, not about the process. The review item is a list of constructors. If you cannot list them, you do not know the endpoint’s posture.
Pin and test, because defaults move
Parser projects do change defaults after widely discussed bugs. They also fork, wrap, and re-expose settings. Pin the version. Read the notes when you bump it. Keep a test that submits a document with a document type to each XML endpoint and expects rejection. The test is how you notice a wrapper that regressed.
A substring filter at the edge can sit in front of that test as a cheap reject, but it is not the assertion you want. Assert that the hardened parser, or the library configured to use it, is what ran. A filter that returns early can hide a parser that would have accepted the document.
Build the route inventory
Search the codebase and the lockfile for XML parsers, and then search product language for import, SSO, SOAP, SVG, and previews. The second search finds routes the first search names only inside a dependency. Write the list down next to the helper you expect them to use.
People affected are the owners of files and internal services the process can reach if a forgotten parser fetches. That is the impact to put on the ticket. Do not prove it by aiming a document at a real internal file. The missing configuration is the finding.
What you change
Point libraries at your factory when they allow a parser to be injected. Replace libraries that do not and that parse untrusted XML with defaults you cannot change. Reject formats you do not need. One helper, one test per endpoint, one inventory.
When a new dependency brings a parser, the dependency review should ask whether untrusted bytes can reach it. If the answer is yes and the flags are not set, the dependency is not ready to merge. That question is cheaper than a second parser in production.
Check yourself
Recognition and the fix. Nothing here is a procedure.
Your parser factory disables entities. A library used by the same route builds its own parser with defaults and parses the upload. What failed?
Sibling techniques
Pages at the same depth, plus a lab and a glossary card for this one.