Summary
An XML External Entity (XXE) vulnerability in Symfony's Crawler::addXmlContent() allows attacker-controlled XML to resolve external entities when DOMDocument::$validateOnParse is set to true.
If an application passes untrusted XML into the crawler, an attacker may be able to read local files via file:// entities or access other sensitive resources on the server.
Affected context
This vulnerability occurs in Symfony-based applications that use Crawler::addXmlContent() with XML derived from user input or other untrusted sources.
It is relevant when DOMDocument parsing is performed with validation enabled, which reactivates external entity resolution.
The risk is higher in deployments where the PHP process can access sensitive files or internal network resources that might be referenced by XML entities.
Exploit preconditions
- Attack surface: HTTP endpoints or other interfaces that feed XML into Crawler::addXmlContent()
- Required access: Ability to supply or influence XML content processed by Symfony's crawler
- Trigger point: Invocation of addXmlContent() on attacker-controlled XML when DOMDocument validation is enabled
- Why exploitation is possible: Setting DOMDocument::$validateOnParse = true re-enables external entity resolution, allowing expansion of file:// and potentially other external entities
Why this happens
The root cause lies in how XML parsing is configured within Symfony's crawler component.
By setting DOMDocument::$validateOnParse = true prior to loadXML(), the code implicitly reactivates external entity resolution, contrary to secure parser defaults.
This maps to CWE-611: Improper Restriction of XML External Entity Reference, where XML is parsed without adequately disabling external entity expansion, permitting access to local or remote resources referenced in the XML.
Potential impact
- An attacker may read local files accessible to the PHP process using file:// entities
- Sensitive configuration data (such as credentials or API keys) could be disclosed
- Internal network endpoints and services might be probed or accessed via specially crafted entities
- Application-level data confidentiality can be compromised depending on file and network access
General mitigation guidance
Mitigation focuses on hardening XML parsing and reducing trust in XML inputs.
Recommended patterns include:
- Ensuring XML parsers run with external entity resolution disabled, even when validation or schema checks are enabled
- Avoiding the use of validating parsers on untrusted XML, or strictly isolating them from sensitive resources
- Treating XML from clients and third-party systems as untrusted and applying schema validation without enabling entity expansion
- Designing applications so that processes handling untrusted XML operate with least privilege and minimal filesystem and network visibility
How teams detect issues like this
Detection can rely on reviewing XML parsing configurations and usages of DOMDocument in the codebase.
Effective strategies include:
- Static analysis rules that flag DOMDocument::$validateOnParse being set to true in code paths handling untrusted XML
- Code review checklists that require verifying external entity settings whenever XML parsing is introduced or modified
- Security policies that mandate safe XML parsing wrappers or factory methods with XXE protections baked in
- Use of automated scanning tools configured to identify XXE risk patterns and insecure parser options

