← PHP / Laravel · Contents

PHP-092 / Advanced

XML Billion Laughs (entity expansion DoS)

A05:2021 Security Misconfiguration · CWE-776 Improper Restriction of Recursive Entity References

Why is this a problem?

Nested entities cause memory expansion of several gigabytes.

How to fix it

php
$dom = new DOMDocument(); $dom->loadXML($request->getContent(), LIBXML_NONET);  // Remove NOENT and limit size

Further reading