Membrane API Gateway returns an error with the title Request discarded by xmlProtection when the xmlProtection plugin discards a request because its content is not XML, or because a multipart body or the document cannot be processed.
The response contains the title Request discarded by xmlProtection, a detail that describes the reason and names the affected part, the problem type https://membrane-api.io/problems/user and a link to this page. The type user means that the request caused the problem, not an internal failure of the gateway. The status depends on the case:
The request, or a part of a multipart request, is not XML.
A multipart body cannot be processed, or the document could not be read or rewritten while it was scanned.
Attacks and limit violations in the XML document itself, such as too deep nesting or too many attributes, are reported with a different problem type.
The xmlProtection plugin protects backends against XML attacks. It scans XML bodies, enforces limits such as maxDepth and maxAttributeCount, and can remove the DTD. See Protection Against XML Attacks.
api:
port: 2000
flow:
- xmlProtection:
maxDepth: 50
removeDTD: true
target:
url: https://api.predic8.de
api:
port: 2000
flow:
- xmlProtection:
maxDepth: 50
removeDTD: true
target:
url: https://api.predic8.de
The request Content-Type is not an XML type, or it is missing. xmlProtection does not inspect a body without an XML Content-Type and rejects it while otherContentTypes is reject, the default. The result is 415.
A part of a multipart body is not XML, for example a file attachment next to an XML part, while otherContentTypes is reject. The result is 415.
A multipart part is larger than maxSize, is itself a multipart, uses an unsupported Content-Transfer-Encoding, or the multipart structure is malformed. The result is 400.
The document could not be read or rewritten while it was scanned, for example when removing the DTD, or a rewritten part cannot be put back into the multipart body safely. The result is 400.
Content-Type such as application/xml or text/xml, and well-formed multipart bodies.otherContentTypes: skip to let non-XML bodies or parts pass unchecked.maxSize. To cap the size of the whole request, use the limit plugin.By default, Membrane runs in development mode and adds details to error responses that help you find the problem. These details may reveal information about your setup. In production, turn them off:
configuration:
production: trueconfiguration: production: true
Add the configuration document to your apis.yaml and separate it from the APIs with ---.
Configuration reference:
Tutorials with runnable examples:
Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.