Join our Newsletter — 33% off our NHI Course

Billion Laughs Attack

The billion laughs attack is an XML denial of service technique that uses nested entity expansion to multiply a small document into a huge processing burden. The parser repeatedly expands references until memory or CPU is exhausted. The result is service slowdown or outage rather than direct data theft.

How the attack works

A billion laughs attack exploits XML entity expansion to turn a tiny input into an outsized parser workload. The danger is not the document size itself, but the repeated recursive expansion step that can multiply processing overhead far beyond the original payload.

Well-formed XML parsers may allow entity references and nested substitutions, which makes this technique effective when expansion limits are weak or absent. The attack is usually aimed at the parser layer, so the impact depends on how strictly the application constrains XML features before processing user-controlled input.

Because the attack weaponises parser behaviour rather than malformed syntax alone, it can succeed even when the XML looks harmless at a glance. That makes it a classic example of a resource-exhaustion weakness hidden inside otherwise valid data handling.

Why it causes denial of service

The failure mode is amplification. Each entity expansion can trigger more expansions, consuming CPU cycles, memory, and sometimes stack or intermediate buffer space until the parser slows down, times out, or crashes. In practice, the service may become unresponsive long before the full expansion completes.

This is closely related to other parser-driven denial-of-service patterns, where a small request forces disproportionate work. For broader context on real-world abuse paths and compromise patterns, see The 52 NHI breaches Report and 52 NHI Breaches Analysis, which show how attack mechanics often exploit trusted processing paths rather than directly breaking in.

The operational result is usually service degradation or outage, not data theft. That distinction matters because availability monitoring, request timeouts, and parser error handling become part of the defensive picture, not just payload validation.

Where defenders usually fail

The weakness typically appears when applications accept XML from untrusted sources and leave default parser features enabled. If entity expansion, external entity processing, or recursion depth are not controlled, the parser may keep expanding until it exhausts resources.

Defenders also fail when they assume “valid XML” means “safe XML.” A document can be syntactically correct and still be operationally dangerous if the parser is allowed to perform unbounded work on attacker-supplied content.

Useful hardening usually includes disabling DTD and entity processing where business logic does not require it, enforcing strict size and depth limits, and isolating XML handling from high-value runtime resources. The relevant control idea is to make the parser predictably bounded even when the input is adversarial.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Agentic AI Top 10 address the attack and risk surface, while CIS Controls v8 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
CIS Controls v8 CIS 4 — Secure Configuration of Enterprise Assets and Software Limits unsafe XML parser settings and expansion behaviour in software configurations.
CIS 8 — Audit Log Management Supports detection of repeated parse failures and resource exhaustion patterns.
Recommendation — Harden XML parsers by disabling risky defaults and enforcing secure configuration baselines. Monitor parser errors and resource spikes to detect XML abuse early.
OWASP Agentic AI Top 10 LLM/APP-10 — Unrestricted Resource Consumption Covers inputs that trigger excessive compute or memory use through controlled processing paths.
Recommendation — Cap parser work and input complexity to prevent attacker-driven resource exhaustion.
NIST CSF 2.0 PR.PT — Protective Technology Supports technical safeguards that constrain dangerous parser behaviour.
DE.CM — Continuous Monitoring Supports visibility into service degradation caused by parser abuse.
Recommendation — Apply protective technology controls to bound XML processing and prevent runaway expansion. Continuously monitor for abnormal CPU, memory, and request failure patterns during XML ingestion.

Practitioner Guidance

What to watch for: Treat any XML intake path that accepts external or semi-trusted content as a potential availability choke point. Parser defaults, recursion depth, and expansion limits should be reviewed as part of secure application configuration, especially where XML enters authentication, integration, or messaging workflows.

Practitioner takeaway: If XML is not essential, remove it from the attack surface; if it is essential, make sure the parser can never do unbounded work on attacker-controlled input.

Risk and Threat Considerations

The primary risk is availability loss, but the business impact can extend to queue buildup, failed integrations, delayed transactions, and cascading service degradation. Because the attack can be launched with a very small request, it is attractive when an adversary wants cheap, repeatable disruption.

Failure mechanism: Nested entity references force the parser into exponential or near-exponential expansion work, exhausting CPU and memory before the application can safely complete processing.

Impact: The affected service may slow down, time out, or crash, creating a denial of service condition that can ripple into dependent systems and customer-facing workflows.