Fix it in your stack

Tested fixes for CWE-611 in Flask, Spring Boot and ASP.NET Core: the vulnerable code, the fix, a plausible fix that still fails, and the regression tests.

Definition

MITRE’s description of CWE-611: The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.

Common consequences MITRE lists

  • Confidentiality: Read Application Data; Read Files or Directories
  • Integrity: Bypass Protection Mechanism
  • Availability: DoS: Resource Consumption (CPU); DoS: Resource Consumption (Memory)

Why it matters

XXE turns an XML upload, SOAP call or other XML input into file disclosure and SSRF, and entity expansion can take the parser down.

How to prevent it

  • Disable DTD processing and external entity resolution in every XML parser configuration.
  • Prefer simpler formats such as JSON where XML is not required.
  • Bound document size and depth, and test with external-entity and entity-expansion payloads.

Guides on this site

Practice

References

  1. CWE-611 in the MITRE CWE list (version 4.20)
  2. OWASP XML External Entity Prevention Cheat Sheet

List data from MITRE; the name, definition and consequences are from MITRE’s CWE 4.20 catalogue. A guide is listed as the main subject when the weakness is what the guide is about, and as covering it when a dedicated section or worked example addresses it.

CWE content: Copyright © 2006–2026, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. CWE™ is free to use by any organization or individual for any research, development, and/or commercial purposes, per these CWE Terms of Use. Accordingly, The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. Any copy you make for such purposes is authorized on the condition that you reproduce MITRE’s copyright designation and this license in any such copy. CWE is a trademark of The MITRE Corporation. CWE Terms of Use.