/

CVE-2026-24400

Severity:

CRITICAL RISK

(9.1)

XML External Entity (XXE) Vulnerability in AssertJ

CVE-2026-24400

Analyzed

Vulnerability type

Category:

XML External Entity (XXE) Vulnerability

CWE:

CWE-611

Impact:

Information Disclosure, Server-Side Request Forgery (SSRF), and Denial of Service

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

AssertJ's XML formatting and comparison utilities process XML with default DocumentBuilderFactory settings, leaving XML external entities and DTDs enabled.

When applications pass untrusted XML into isXmlEqualTo(CharSequence) or xmlPrettyFormat(String), attackers may read local files, trigger SSRF, or cause denial-of-service via entity expansion.

Affected context

This vulnerability manifests in Java applications and test suites that:

  • Use AssertJ versions from 1.4.0 up to (but excluding) 3.27.7
  • Call isXmlEqualTo(CharSequence) from org.assertj.core.api.AbstractCharSequenceAssert

and/or xmlPrettyFormat(String) from org.assertj.core.util.xml.XmlStringPrettyFormatter

  • Pass XML content that can be influenced, controlled, or injected by an attacker

It is particularly relevant where test helpers or diagnostics inadvertently execute against untrusted XML (for example, parsing responses from external services or inputs stored in test fixtures that derive from user data).

Exploit preconditions

  • Attack surface: Java/JVM code paths that invoke:
  • AbstractCharSequenceAssert.isXmlEqualTo(CharSequence)
  • XmlStringPrettyFormatter.xmlPrettyFormat(String)
  • Required access: Ability to supply or modify XML content passed into these APIs (e.g., via user-submitted data, test harness input, logs, or external service responses).
  • Trigger point: The vulnerable methods internally call toXmlDocument(String), which creates a DocumentBuilderFactory with default, insecure settings, allowing DTDs and external entities.
  • Why exploitation is possible: Because XXE-related features are not disabled, the XML parser resolves external entities. Crafted XML can reference local files (file://), internal network endpoints (http://, https://), or use recursive entities (Billion Laughs) that the parser will attempt to process.

Why this happens

The root cause is the use of DocumentBuilderFactory with default configuration in org.assertj.core.util.xml.XmlStringPrettyFormatter.toXmlDocument(String), without explicitly disabling DTDs and external entities or enabling secure processing features.

This aligns with CWE-611: Improper Restriction of XML External Entity Reference, where XML parsers process external entities from untrusted input, enabling attackers to reach resources beyond the intended trust boundary. In this case, AssertJ's XML utilities, originally meant as testing helpers, behave as generic XML parsers but do not enforce secure parsing options, exposing XXE when given untrusted XML data.

Potential impact

  • Read arbitrary local files accessible to the AssertJ process via file:// URIs (e.g., /etc/passwd, application configuration files, private keys).
  • Perform Server-Side Request Forgery (SSRF) by making the application initiate HTTP/HTTPS requests to internal or external endpoints.
  • Exfiltrate data from internal network services by encoding responses in XML entity expansions.
  • Cause Denial of Service via entity expansion attacks such as the "Billion Laughs" pattern, consuming CPU and memory.
  • Assist in reconnaissance of the host and internal network environment, potentially supporting further compromise.

General mitigation guidance

Effective mitigation focuses on treating all XML input as untrusted by default and enforcing secure parsing patterns:

  • Prefer alternative assertion libraries specifically designed for XML comparison (e.g., XMLUnit) that default to secure XML parsing and provide documented XXE hardening options.
  • Configure XML parsers with secure processing features when custom XML handling is required:
  • Disable DTDs and external entity resolution.
  • Enable secure processing limits (entity expansion, depth, and size limits).
  • Avoid using test utilities or assertion helpers that perform XML parsing on untrusted or user-controlled XML. Restrict such usage to controlled, static test data.
  • Isolate XML parsing logic into well-reviewed, shared utility components that enforce safe defaults, rather than ad hoc creation of DocumentBuilderFactory in multiple locations.
  • Apply least privilege to the runtime environment: restrict file system access where feasible and limit outbound network access from testing or application processes to reduce the blast radius of any XXE that occurs.

How teams detect issues like this

Detection generally relies on combining code-level analysis, configuration review, and targeted testing:

  • Static analysis and code search:
  • Search for uses of DocumentBuilderFactory.newInstance() and check whether secure features are explicitly set:
  • Disabling DTDs and external entities
  • Enabling secure processing
  • Flag direct uses of isXmlEqualTo(CharSequence) and XmlStringPrettyFormatter.xmlPrettyFormat(String) in codebases that may handle external or user-derived XML.
  • Code review practices:
  • Treat any XML parsing in assertions, tests, or debug utilities as security-relevant, especially in integration or end-to-end tests that may touch real services or external inputs.
  • Verify that XML handling utilities are centralized and hardened rather than duplicated.
  • Dynamic testing:
  • Introduce XXE proof-of-concept payloads into test XML inputs to observe whether outbound requests, file reads, or DoS symptoms occur.
  • Automated tooling:
  • Configure SAST tools with rules for CWE-611 to flag insecure XML parser configurations.
  • Use dependency scanning tools and SBOM-based policies to highlight vulnerable AssertJ versions and encourage secure upgrades.

Sources

SourceLink
cheatsheetseries.owasp.orgcheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html
github.comgithub.com/assertj/assertj/commit/85ca7eb6609bb179c043b85ae7d290523b1ba79a
github.comgithub.com/assertj/assertj/releases/tag/assertj-build-3.27.7
github.comgithub.com/assertj/assertj/security/advisories/GHSA-rqfh-9r24-8c9r

Frequently asked

questions

Yes, if an attacker can cause the application or test infrastructure to pass attacker-controlled XML into isXmlEqualTo(CharSequence) or xmlPrettyFormat(String). In such cases, exploitation can occur remotely via the same interfaces through which the XML is supplied.

It depends on where and how AssertJ is used. If untrusted XML comes from authenticated users or internal services, an attacker must reach those interfaces. If XML is only taken from local files maintained by developers, the risk is lower. The critical factor is whether an attacker can influence the XML that these methods parse.

Replace usage of isXmlEqualTo(CharSequence) with a hardened XML comparison library that enforces secure parsing (such as XMLUnit), and avoid using XmlStringPrettyFormatter with untrusted XML. Centralize XML parsing behind secure helper utilities that disable DTDs and external entities and enable secure processing.

Adopt a standard secure XML parsing configuration across the codebase, treat XML as untrusted by default, and include XXE checks in code review and static analysis. Prefer libraries and frameworks that document secure defaults, and avoid creating new XML parser instances without explicitly configuring them for security.

Find out what's already
exploitable in your codebase.