CWE-407
Weakness Allowed-with-ReviewInefficient Algorithmic Complexity
Abstraction: Class · Status: Incomplete
An algorithm in a product has an inefficient worst-case computational complexity that may be detrimental to system performance and can be triggered by an attacker, typically using crafted manipulations that ensure that the worst case is being reached.
Mapping guidance
This CWE entry is a Class and might have Base-level children that would be more appropriate
Examine children of this entry to see if there is a better fit
Modes of introduction
Detection methods
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Effectiveness: High
Content history
updated Time_of_Introduction
updated Common_Consequences, Relationships, Other_Notes, Taxonomy_Mappings
updated Functional_Areas, Other_Notes
updated Common_Consequences
updated Applicable_Platforms, Likelihood_of_Exploit
updated Common_Consequences
updated Observed_Examples, Relationships
updated Relationships
updated Relationships
updated Likelihood_of_Exploit
updated Name, Relationships, Type
updated Relationships
updated Relationships
updated References, Relationships
updated References
updated Alternate_Terms, Observed_Examples, Relationships
updated Demonstrative_Examples, Observed_Examples, References
updated Relationships
updated Mapping_Notes
updated Weakness_Ordinalities
updated Detection_Factors, References
704 vulnerabilities reference this CWE, most recent first.
GHSA-8XQV-HM62-6R4G
Vulnerability from github – Published: 2026-10-22 21:32 – Updated: 2026-10-22 21:32Mistune before 3.3.0 contains an inefficient algorithmic complexity vulnerability in parse_link_text that allows remote attackers to cause denial of service through unbalanced square brackets. Attackers can submit markdown containing long runs of unmatched brackets to mistune.html(), triggering repeated forward scans that stall worker processes for minutes.
{
"affected": [],
"aliases": [
"CVE-2026-115347"
],
"database_specific": {
"cwe_ids": [
"CWE-407"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-10-22T19:17:40Z",
"severity": "HIGH"
},
"details": "Mistune before 3.3.0 contains an inefficient algorithmic complexity vulnerability in parse_link_text that allows remote attackers to cause denial of service through unbalanced square brackets. Attackers can submit markdown containing long runs of unmatched brackets to mistune.html(), triggering repeated forward scans that stall worker processes for minutes.",
"id": "GHSA-8xqv-hm62-6r4g",
"modified": "2026-10-22T21:32:36Z",
"published": "2026-10-22T21:32:36Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/lepture/mistune/security/advisories/GHSA-f32h-38gf-rg5r"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-115347"
},
{
"type": "WEB",
"url": "https://www.vulncheck.com/advisories/mistune-before-3.3.0-quadratic-denial-of-service-via-parse-link-text"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
"type": "CVSS_V4"
}
]
}
GHSA-93Q9-CRCW-VWGQ
Vulnerability from github – Published: 2025-11-28 09:30 – Updated: 2026-06-02 15:31In libexpat through 2.7.3, a crafted file with an approximate size of 2 MiB can lead to dozens of seconds of processing time.
{
"affected": [],
"aliases": [
"CVE-2025-66382"
],
"database_specific": {
"cwe_ids": [
"CWE-407"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-11-28T07:15:57Z",
"severity": "LOW"
},
"details": "In libexpat through 2.7.3, a crafted file with an approximate size of 2 MiB can lead to dozens of seconds of processing time.",
"id": "GHSA-93q9-crcw-vwgq",
"modified": "2026-06-02T15:31:50Z",
"published": "2025-11-28T09:30:17Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-66382"
},
{
"type": "WEB",
"url": "https://github.com/libexpat/libexpat/issues/1076"
},
{
"type": "WEB",
"url": "https://cert-portal.siemens.com/productcert/html/ssa-082556.html"
},
{
"type": "WEB",
"url": "https://cert-portal.siemens.com/productcert/html/ssa-253495.html"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2025/12/02/1"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L",
"type": "CVSS_V3"
}
]
}
GHSA-93R5-FHX6-VMG9
Vulnerability from github – Published: 2026-09-08 21:00 – Updated: 2026-09-08 21:00Summary
xmldom's malformed-input error-recovery path has two quadratic-time (O(n²)) behaviors that a
single crafted input triggers together, so a tiny, highly compressible document (tens of KB) stalls
the Node.js event loop for multiple seconds. It is reachable from DOMParser.parseFromString under
default options — i.e. from unauthenticated, network-delivered XML — making this an unauthenticated
denial of service. One of the two behaviors, the normalize() adjacent-text merge, is additionally
reachable programmatically — via a plain normalize() call on a DOM built with adjacent text nodes,
independent of the parser — so its fix must live in normalize(), not only in a parser bound.
Details
Finding A — parseElementStartPart quadratic re-scan
A < character is not a delimiter in any tag-parsing state, so parseElementStartPart scans
forward character-by-character over any embedded < until it reaches the next > (or end of
input), then validates the accumulated slice as a tag name and throws invalid tagName: on failure.
The main loop catches this, reports an error, sets end = -1, and recovers by advancing a single
character (appendText(Math.max(tagStart, start) + 1)). With a long run of < and a distant >,
each of the O(n) recovery retries performs an O(n) scan plus an O(n) anchored regex validation over
the growing candidate ⇒ O(n²).
Code (0.9.x, bb7a085dc5ba1eea3212388509b97bb4b4af32b9):
parseElementStartPartcharacter scan — https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/sax.js#L263-L461- tag-name validation (
setTagName→ throwsinvalid tagName) — https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/sax.js#L886-L891 - main-loop
catch→error+end = -1— https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/sax.js#L234-L242 - single-character recovery fallback — https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/sax.js#L247
Code (0.8.x, e5c14802592685bb872c042c54c3f73758875c85):
parseElementStartPart— https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/sax.js#L227catch→error+end = -1— https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/sax.js#L202-L208- recovery fallback — https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/sax.js#L213
setTagNamevalidation — https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/sax.js#L616-L621
Finding B — normalize() adjacent-text O(K²) merge
endDocument() calls document.normalize(). For a parent with K adjacent text nodes (produced by
the one-character recovery of Finding A), normalize() performs K−1 merges. Each merge does a
removeChild — which re-indexes all child nodes of the parent (O(K)) — and an appendData —
which rebuilds the accumulator string this.data + text (O(K)). Total: O(K²).
Well-formed XML cannot produce adjacent text-node siblings through the parser (each text run is one
node; comments, CDATA, PIs, and elements sit between runs), so the parse-path trigger for Finding B
is the malformed-input recovery that emits single-character text nodes. The same O(K²) merge is,
however, independently reachable via the public normalize() API on a programmatically built tree
(see "Finding B is additionally reachable programmatically" below).
Code (0.9.x, bb7a085dc5ba1eea3212388509b97bb4b4af32b9):
endDocument→normalize()— https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/dom-parser.js#L418-L420normalize()adjacent-text merge — https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/dom.js#L1336-L1356removeChildre-index-all branch — https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/dom.js#L1788-L1798appendDatastring rebuild — https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/dom.js#L2786-L2790
Code (0.8.x, e5c14802592685bb872c042c54c3f73758875c85):
endDocument→normalize()— https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/dom-parser.js#L213-L214normalize()merge — https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/dom.js#L529-L549removeChildre-index-all branch — https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/dom.js#L756-L773appendDatastring rebuild — https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/dom.js#L1533
Finding B is additionally reachable programmatically (no parser involved)
Node.prototype.normalize() is public API on every Document/Element. A tree built entirely through
the ordinary DOM API — new DOMImplementation().createDocument(...), then K× createTextNode +
appendChild on one parent — reaches the same O(K²) merge when the application calls normalize(),
with no parsing and no error-recovery. The parser is only one of the two callers of the
vulnerable merge:
- the parser's automatic
endDocument()→document.normalize()(the parse-path trigger above), and - any explicit application call to the public
normalize()on a tree with adjacent text nodes.
XMLSerializer does not call normalize(), so serializing an un-merged tree is O(total text), not
O(K²); the O(K²) surface is exactly those two normalize() callers. Consequently a parser-side bound
alone cannot remediate Finding B — the fix must live in normalize().
Affected Versions
Both findings are present across the full published @xmldom/xmldom history — both
currently-maintained versions (0.8.x and 0.9.x) are affected — and across the retired unscoped
xmldom line. Finding B's normalize() merge is additionally reachable programmatically: a
direct normalize() call on a DOM built with adjacent text nodes hits the same O(K²) merge,
independent of the parser — so, unlike Finding A, it does not require the malformed-input recovery
path.
Proof of Concept
Default DOMParser, no options. The input is trivially compressible (a< / a<> repeated) and
never throws — it is parsed via the recovery path.
const { DOMParser } = require('@xmldom/xmldom');
// Silence the expected `error`-level recovery reports (default handler logs
// them to console.error without throwing; only fatalError throws).
console.error = function () {};
function timeParse(label, xml, mime) {
const t0 = process.hrtime.bigint();
new DOMParser().parseFromString(xml, mime); // completes; no exception
const ms = Number(process.hrtime.bigint() - t0) / 1e6;
console.log(label + ' bytes=' + Buffer.byteLength(xml) + ' time=' + ms.toFixed(1) + ' ms');
}
for (const N of [4000, 8000, 16000, 32000]) {
// Finding A: long re-scans, O(n^2) during parse.
timeParse('A N=' + N, '<r>' + 'a<'.repeat(N) + '</r>', 'text/xml');
// Finding B: short re-scans (cheap parse) but K adjacent text nodes -> O(K^2) in normalize().
timeParse('B N=' + N, '<r>' + 'a<>'.repeat(N) + '</r>', 'text/html');
// Combined: ONE input hits both A and B under the default parser.
timeParse('C N=' + N, '<r>' + 'a<'.repeat(N) + '</r>', 'text/xml');
}
Measured on Node v18.20.8 (absolute ms vary by host; the load-bearing fact is that doubling the input ~quadruples the time — canonical O(n²)):
Finding A, isolated ("<r>" + "a<"×N + "</r>", normalize disabled to isolate the re-scan):
| N | input bytes | @xmldom/xmldom 0.9.10 |
0.8.13 |
|---|---|---|---|
| 2000 | 4007 | 43 ms | 37 ms |
| 4000 | 8007 | 129 ms | 106 ms |
| 8000 | 16007 | 434 ms | 424 ms |
| 16000 | 32007 | 1629 ms | 1611 ms |
Finding B, isolated ("<r>" + "a<>"×N + "</r>", time attributable to normalize()):
| K (N) | input bytes | 0.9.10 | 0.8.13 |
|---|---|---|---|
| 4000 | 12007 | 120 ms | 165 ms |
| 8000 | 24007 | 589 ms | 771 ms |
| 16000 | 48007 | 3142 ms | 4448 ms |
| 32000 | 96007 | 12127 ms | 12951 ms |
Combined (default parser, both findings; "<r>" + "a<"×N + "</r>"):
| N | input bytes | 0.9.10 | 0.8.13 |
|---|---|---|---|
| 4000 | 8007 | 341 ms | 397 ms |
| 8000 | 16007 | 1894 ms | 1641 ms |
| 16000 | 32007 | 4398 ms | 7661 ms |
~32 KB of input → several seconds of single-threaded event-loop stall.
Finding B via the public normalize() API (no parser)
const { DOMImplementation } = require('@xmldom/xmldom');
function timeNormalize(K) {
const doc = new DOMImplementation().createDocument(null, 'r', null);
const el = doc.documentElement;
for (let i = 0; i < K; i++) el.appendChild(doc.createTextNode('x')); // K adjacent text nodes
const t0 = process.hrtime.bigint();
doc.normalize(); // O(K^2) merge — no parsing involved
const ms = Number(process.hrtime.bigint() - t0) / 1e6;
console.log('K=' + K + ' time=' + ms.toFixed(1) + ' ms');
}
for (const K of [2000, 4000, 8000, 16000, 32000]) timeNormalize(K);
Measured on Node v18.20.8 (doubling K ~quadruples the time — O(K²)):
| K | 0.9.10 | 0.8.13 |
|---|---|---|
| 2000 | 5.7 ms | 5.6 ms |
| 32000 | 1263 ms | 1704 ms |
This path is reachable by any application that builds a DOM from attacker-influenced data and calls
normalize(), entirely independent of DOMParser.
Impact
Availability only: a single parse of a small crafted document blocks the Node.js event loop for the
duration of the quadratic work (multiple seconds at tens of KB; larger inputs scale as O(n²)). No
memory blow-up beyond transient strings, no data exposure, no integrity impact. Because XML is
routinely accepted from untrusted sources and parsed with default options, one request can stall a
server. The payloads are highly compressible, so any endpoint accepting compressed XML faces
additional amplification. Finding B is additionally reachable via an explicit normalize() call on a
programmatically built DOM (see Proof of Concept), so applications that construct a document from attacker-influenced
data and normalize it are exposed even without parsing.
Severity note
The complexity is quadratic, not exponential, so a multi-second stall requires
tens-to-hundreds of KB of input. VA:H reflects that xmldom applies no input-size limit and the
path runs on default-options parsing, so a single unbounded parse can fully stall the event loop.
Fix Applied
Two independent, non-breaking fixes shipped together — each alone leaves the other's quadratic cost dominating the default parse.
Finding A — terminate the malformed tag-name scan at an embedded <, so error recovery is linear instead of O(n²). DOM output is unchanged; only the reported error-message text differs (error strings are not a semver contract).
Finding B — merge adjacent text nodes in normalize() in O(K) instead of O(K²), which also closes the same slowdown reachable programmatically through a direct normalize() call. Both ship on both maintained versions.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 0.8.14"
},
"package": {
"ecosystem": "npm",
"name": "@xmldom/xmldom"
},
"ranges": [
{
"events": [
{
"introduced": "0.7.0"
},
{
"fixed": "0.8.15"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 0.9.11"
},
"package": {
"ecosystem": "npm",
"name": "@xmldom/xmldom"
},
"ranges": [
{
"events": [
{
"introduced": "0.9.0"
},
{
"fixed": "0.9.12"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "npm",
"name": "xmldom"
},
"ranges": [
{
"events": [
{
"introduced": "0.3.0"
},
{
"last_affected": "0.6.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-83614"
],
"database_specific": {
"cwe_ids": [
"CWE-400",
"CWE-407"
],
"github_reviewed": true,
"github_reviewed_at": "2026-09-08T21:00:41Z",
"nvd_published_at": "2026-09-01T15:17:39Z",
"severity": "HIGH"
},
"details": "## Summary\n\n`xmldom`\u0027s malformed-input **error-recovery path** has two quadratic-time (O(n\u00b2)) behaviors that a\nsingle crafted input triggers together, so a tiny, highly compressible document (tens of KB) stalls\nthe Node.js event loop for multiple seconds. It is reachable from `DOMParser.parseFromString` under\n**default options** \u2014 i.e. from unauthenticated, network-delivered XML \u2014 making this an unauthenticated\ndenial of service. One of the two behaviors, the `normalize()` adjacent-text merge, is **additionally\nreachable programmatically** \u2014 via a plain `normalize()` call on a DOM built with adjacent text nodes,\nindependent of the parser \u2014 so its fix must live in `normalize()`, not only in a parser bound.\n\n## Details\n\n### Finding A \u2014 `parseElementStartPart` quadratic re-scan\n\nA `\u003c` character is not a delimiter in any tag-parsing state, so `parseElementStartPart` scans\nforward character-by-character over any embedded `\u003c` until it reaches the next `\u003e` (or end of\ninput), then validates the accumulated slice as a tag name and throws `invalid tagName:` on failure.\nThe main loop catches this, reports an `error`, sets `end = -1`, and recovers by advancing a single\ncharacter (`appendText(Math.max(tagStart, start) + 1)`). With a long run of `\u003c` and a distant `\u003e`,\neach of the O(n) recovery retries performs an O(n) scan plus an O(n) anchored regex validation over\nthe growing candidate \u21d2 **O(n\u00b2)**.\n\nCode (0.9.x, `bb7a085dc5ba1eea3212388509b97bb4b4af32b9`):\n\n- `parseElementStartPart` character scan \u2014 https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/sax.js#L263-L461\n- tag-name validation (`setTagName` \u2192 throws `invalid tagName`) \u2014 https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/sax.js#L886-L891\n- main-loop `catch` \u2192 `error` + `end = -1` \u2014 https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/sax.js#L234-L242\n- single-character recovery fallback \u2014 https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/sax.js#L247\n\nCode (0.8.x, `e5c14802592685bb872c042c54c3f73758875c85`):\n\n- `parseElementStartPart` \u2014 https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/sax.js#L227\n- `catch` \u2192 `error` + `end = -1` \u2014 https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/sax.js#L202-L208\n- recovery fallback \u2014 https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/sax.js#L213\n- `setTagName` validation \u2014 https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/sax.js#L616-L621\n\n### Finding B \u2014 `normalize()` adjacent-text O(K\u00b2) merge\n\n`endDocument()` calls `document.normalize()`. For a parent with K adjacent text nodes (produced by\nthe one-character recovery of Finding A), `normalize()` performs K\u22121 merges. Each merge does a\n`removeChild` \u2014 which re-indexes **all** child nodes of the parent (O(K)) \u2014 and an `appendData` \u2014\nwhich rebuilds the accumulator string `this.data + text` (O(K)). Total: **O(K\u00b2)**.\n\nWell-formed XML cannot produce adjacent text-node siblings *through the parser* (each text run is one\nnode; comments, CDATA, PIs, and elements sit between runs), so the **parse-path** trigger for Finding B\nis the malformed-input recovery that emits single-character text nodes. The same O(K\u00b2) merge is,\nhowever, independently reachable via the public `normalize()` API on a programmatically built tree\n(see \"Finding B is additionally reachable programmatically\" below).\n\nCode (0.9.x, `bb7a085dc5ba1eea3212388509b97bb4b4af32b9`):\n\n- `endDocument` \u2192 `normalize()` \u2014 https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/dom-parser.js#L418-L420\n- `normalize()` adjacent-text merge \u2014 https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/dom.js#L1336-L1356\n- `removeChild` re-index-all branch \u2014 https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/dom.js#L1788-L1798\n- `appendData` string rebuild \u2014 https://github.com/xmldom/xmldom/blob/bb7a085dc5ba1eea3212388509b97bb4b4af32b9/lib/dom.js#L2786-L2790\n\nCode (0.8.x, `e5c14802592685bb872c042c54c3f73758875c85`):\n\n- `endDocument` \u2192 `normalize()` \u2014 https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/dom-parser.js#L213-L214\n- `normalize()` merge \u2014 https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/dom.js#L529-L549\n- `removeChild` re-index-all branch \u2014 https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/dom.js#L756-L773\n- `appendData` string rebuild \u2014 https://github.com/xmldom/xmldom/blob/e5c14802592685bb872c042c54c3f73758875c85/lib/dom.js#L1533\n\n### Finding B is additionally reachable programmatically (no parser involved)\n\n`Node.prototype.normalize()` is public API on every `Document`/`Element`. A tree built entirely through\nthe ordinary DOM API \u2014 `new DOMImplementation().createDocument(...)`, then K\u00d7 `createTextNode` +\n`appendChild` on one parent \u2014 reaches the **same** O(K\u00b2) merge when the application calls `normalize()`,\nwith **no** parsing and **no** error-recovery. The parser is only *one* of the two callers of the\nvulnerable merge:\n\n- the parser\u0027s automatic `endDocument()` \u2192 `document.normalize()` (the parse-path trigger above), and\n- any explicit application call to the public `normalize()` on a tree with adjacent text nodes.\n\n`XMLSerializer` does **not** call `normalize()`, so serializing an un-merged tree is O(total text), not\nO(K\u00b2); the O(K\u00b2) surface is exactly those two `normalize()` callers. Consequently a parser-side bound\nalone cannot remediate Finding B \u2014 the fix must live in `normalize()`.\n\n## Affected Versions\n\nBoth findings are present across the full published `@xmldom/xmldom` history \u2014 both\ncurrently-maintained versions (`0.8.x` and `0.9.x`) are affected \u2014 and across the retired unscoped\n`xmldom` line. Finding B\u0027s `normalize()` merge is additionally reachable **programmatically**: a\ndirect `normalize()` call on a DOM built with adjacent text nodes hits the same O(K\u00b2) merge,\nindependent of the parser \u2014 so, unlike Finding A, it does not require the malformed-input recovery\npath.\n\n## Proof of Concept\n\nDefault `DOMParser`, no options. The input is trivially compressible (`a\u003c` / `a\u003c\u003e` repeated) and\nnever throws \u2014 it is parsed via the recovery path.\n\n```js\nconst { DOMParser } = require(\u0027@xmldom/xmldom\u0027);\n\n// Silence the expected `error`-level recovery reports (default handler logs\n// them to console.error without throwing; only fatalError throws).\nconsole.error = function () {};\n\nfunction timeParse(label, xml, mime) {\n const t0 = process.hrtime.bigint();\n new DOMParser().parseFromString(xml, mime); // completes; no exception\n const ms = Number(process.hrtime.bigint() - t0) / 1e6;\n console.log(label + \u0027 bytes=\u0027 + Buffer.byteLength(xml) + \u0027 time=\u0027 + ms.toFixed(1) + \u0027 ms\u0027);\n}\n\nfor (const N of [4000, 8000, 16000, 32000]) {\n // Finding A: long re-scans, O(n^2) during parse.\n timeParse(\u0027A N=\u0027 + N, \u0027\u003cr\u003e\u0027 + \u0027a\u003c\u0027.repeat(N) + \u0027\u003c/r\u003e\u0027, \u0027text/xml\u0027);\n // Finding B: short re-scans (cheap parse) but K adjacent text nodes -\u003e O(K^2) in normalize().\n timeParse(\u0027B N=\u0027 + N, \u0027\u003cr\u003e\u0027 + \u0027a\u003c\u003e\u0027.repeat(N) + \u0027\u003c/r\u003e\u0027, \u0027text/html\u0027);\n // Combined: ONE input hits both A and B under the default parser.\n timeParse(\u0027C N=\u0027 + N, \u0027\u003cr\u003e\u0027 + \u0027a\u003c\u0027.repeat(N) + \u0027\u003c/r\u003e\u0027, \u0027text/xml\u0027);\n}\n```\n\nMeasured on Node v18.20.8 (absolute ms vary by host; the load-bearing fact is that doubling the\ninput ~quadruples the time \u2014 canonical O(n\u00b2)):\n\nFinding A, isolated (`\"\u003cr\u003e\" + \"a\u003c\"\u00d7N + \"\u003c/r\u003e\"`, normalize disabled to isolate the re-scan):\n\n| N | input bytes | `@xmldom/xmldom` 0.9.10 | 0.8.13 |\n|--:|--:|--:|--:|\n| 2000 | 4007 | 43 ms | 37 ms |\n| 4000 | 8007 | 129 ms | 106 ms |\n| 8000 | 16007 | 434 ms | 424 ms |\n| 16000 | 32007 | 1629 ms | 1611 ms |\n\nFinding B, isolated (`\"\u003cr\u003e\" + \"a\u003c\u003e\"\u00d7N + \"\u003c/r\u003e\"`, time attributable to `normalize()`):\n\n| K (N) | input bytes | 0.9.10 | 0.8.13 |\n|--:|--:|--:|--:|\n| 4000 | 12007 | 120 ms | 165 ms |\n| 8000 | 24007 | 589 ms | 771 ms |\n| 16000 | 48007 | 3142 ms | 4448 ms |\n| 32000 | 96007 | 12127 ms | 12951 ms |\n\nCombined (default parser, both findings; `\"\u003cr\u003e\" + \"a\u003c\"\u00d7N + \"\u003c/r\u003e\"`):\n\n| N | input bytes | 0.9.10 | 0.8.13 |\n|--:|--:|--:|--:|\n| 4000 | 8007 | 341 ms | 397 ms |\n| 8000 | 16007 | 1894 ms | 1641 ms |\n| 16000 | 32007 | 4398 ms | 7661 ms |\n\n~32 KB of input \u2192 several seconds of single-threaded event-loop stall.\n\n### Finding B via the public `normalize()` API (no parser)\n\n```js\nconst { DOMImplementation } = require(\u0027@xmldom/xmldom\u0027);\n\nfunction timeNormalize(K) {\n const doc = new DOMImplementation().createDocument(null, \u0027r\u0027, null);\n const el = doc.documentElement;\n for (let i = 0; i \u003c K; i++) el.appendChild(doc.createTextNode(\u0027x\u0027)); // K adjacent text nodes\n const t0 = process.hrtime.bigint();\n doc.normalize(); // O(K^2) merge \u2014 no parsing involved\n const ms = Number(process.hrtime.bigint() - t0) / 1e6;\n console.log(\u0027K=\u0027 + K + \u0027 time=\u0027 + ms.toFixed(1) + \u0027 ms\u0027);\n}\nfor (const K of [2000, 4000, 8000, 16000, 32000]) timeNormalize(K);\n```\n\nMeasured on Node v18.20.8 (doubling K ~quadruples the time \u2014 O(K\u00b2)):\n\n| K | 0.9.10 | 0.8.13 |\n|--:|--:|--:|\n| 2000 | 5.7 ms | 5.6 ms |\n| 32000 | 1263 ms | 1704 ms |\n\nThis path is reachable by any application that builds a DOM from attacker-influenced data and calls\n`normalize()`, entirely independent of `DOMParser`.\n\n## Impact\n\nAvailability only: a single parse of a small crafted document blocks the Node.js event loop for the\nduration of the quadratic work (multiple seconds at tens of KB; larger inputs scale as O(n\u00b2)). No\nmemory blow-up beyond transient strings, no data exposure, no integrity impact. Because XML is\nroutinely accepted from untrusted sources and parsed with default options, one request can stall a\nserver. The payloads are highly compressible, so any endpoint accepting compressed XML faces\nadditional amplification. Finding B is additionally reachable via an explicit `normalize()` call on a\nprogrammatically built DOM (see Proof of Concept), so applications that construct a document from attacker-influenced\ndata and normalize it are exposed even without parsing.\n\n## Severity note\n\nThe complexity is **quadratic**, not exponential, so a multi-second stall requires\ntens-to-hundreds of KB of input. `VA:H` reflects that xmldom applies **no** input-size limit and the\npath runs on default-options parsing, so a single unbounded parse can fully stall the event loop.\n\n## Fix Applied\n\nTwo independent, non-breaking fixes shipped together \u2014 each alone leaves the other\u0027s quadratic cost dominating the default parse.\nFinding A \u2014 terminate the malformed tag-name scan at an embedded `\u003c`, so error recovery is linear instead of O(n\u00b2). DOM output is unchanged; only the reported error-message text differs (error strings are not a semver contract).\nFinding B \u2014 merge adjacent text nodes in `normalize()` in O(K) instead of O(K\u00b2), which also closes the same slowdown reachable programmatically through a direct `normalize()` call. Both ship on both maintained versions.",
"id": "GHSA-93r5-fhx6-vmg9",
"modified": "2026-09-08T21:00:41Z",
"published": "2026-09-08T21:00:41Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/xmldom/xmldom/security/advisories/GHSA-93r5-fhx6-vmg9"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-83614"
},
{
"type": "WEB",
"url": "https://github.com/xmldom/xmldom/pull/1071"
},
{
"type": "WEB",
"url": "https://github.com/xmldom/xmldom/pull/1072"
},
{
"type": "WEB",
"url": "https://github.com/xmldom/xmldom/commit/0748720b620555f8c222782dcab575cf0cf403b4"
},
{
"type": "WEB",
"url": "https://github.com/xmldom/xmldom/commit/f40ccb861eee0acbf5ee4feb9a34932e87b329c9"
},
{
"type": "PACKAGE",
"url": "https://github.com/xmldom/xmldom"
},
{
"type": "WEB",
"url": "https://github.com/xmldom/xmldom/releases/tag/0.8.15"
},
{
"type": "WEB",
"url": "https://github.com/xmldom/xmldom/releases/tag/0.9.12"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N",
"type": "CVSS_V4"
}
],
"summary": "xmldom: Quadratic-time parsing via the malformed-input recovery path \u2014 `parseElementStartPart` re-scan and `normalize()` adjacent-text merge"
}
GHSA-94XW-8RG2-4FMC
Vulnerability from github – Published: 2024-11-26 21:32 – Updated: 2024-11-26 21:32An issue was discovered in GitLab CE/EE affecting all versions starting from 15.6 prior to 17.4.5, starting from 17.5 prior to 17.5.3, starting from 17.6 prior to 17.6.1 which could cause Denial of Service via integrating a malicious harbor registry.
{
"affected": [],
"aliases": [
"CVE-2024-8177"
],
"database_specific": {
"cwe_ids": [
"CWE-407"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2024-11-26T19:15:31Z",
"severity": "MODERATE"
},
"details": "An issue was discovered in GitLab CE/EE affecting all versions starting from 15.6 prior to 17.4.5, starting from 17.5 prior to 17.5.3, starting from 17.6 prior to 17.6.1 which could cause Denial of Service via integrating a malicious harbor registry.",
"id": "GHSA-94xw-8rg2-4fmc",
"modified": "2024-11-26T21:32:24Z",
"published": "2024-11-26T21:32:24Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-8177"
},
{
"type": "WEB",
"url": "https://hackerone.com/reports/2637996"
},
{
"type": "WEB",
"url": "https://gitlab.com/gitlab-org/gitlab/-/issues/480706"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-9643-4QGH-G8MX
Vulnerability from github – Published: 2026-09-23 21:54 – Updated: 2026-09-23 21:54Elysia v1.4.28 is vulnerable to denial-of-service attacks due to CPU exhaustion in the form data normalization code.
Elysia uses getAll to retrieve value from FormData. It is called directly relative to the total number of key-value pairs in the form data. The total amount of work the for loop has to do grows quadratically, so doubling the number of unique key-value pairs quadruples the amount of work. In the above PoC, each .getAll call scans through all of the n key-value pairs in the form data. Because there are n unique keys in the form data, there are .getAll calls, so in total the form data normalizer has to scan n x n key-value pairs.
Impact
Endpoints using multipart/form-data
Patches
1.4.29
Workarounds
no 100% confirm workaround beside updating the patch
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "elysia"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.4.29"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-56669"
],
"database_specific": {
"cwe_ids": [
"CWE-407",
"CWE-436"
],
"github_reviewed": true,
"github_reviewed_at": "2026-09-23T21:54:50Z",
"nvd_published_at": "2026-07-08T21:16:50Z",
"severity": "HIGH"
},
"details": "Elysia v1.4.28 is vulnerable to denial-of-service attacks due to CPU exhaustion in the form data normalization code.\n\nElysia uses `getAll` to retrieve value from FormData. It is called directly relative to the total number of key-value pairs in the form data. The total amount of work the for loop has to do grows quadratically, so doubling the number of unique key-value pairs quadruples the amount of work. In the above PoC, each .getAll call scans through all of the `n` key-value pairs in the form data. Because there are `n` unique keys in the form data, there are .getAll calls, so in total the form data normalizer has to scan `n` x `n` key-value pairs.\n\n### Impact\nEndpoints using `multipart/form-data`\n\n### Patches\n1.4.29\n\n### Workarounds\nno 100% confirm workaround beside updating the patch",
"id": "GHSA-9643-4qgh-g8mx",
"modified": "2026-09-23T21:54:50Z",
"published": "2026-09-23T21:54:50Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/elysiajs/elysia/security/advisories/GHSA-9643-4qgh-g8mx"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-56669"
},
{
"type": "WEB",
"url": "https://github.com/elysiajs/elysia/commit/8358ff9efbcedf9534995f5977f26b9ceab59329"
},
{
"type": "WEB",
"url": "https://gist.github.com/jviide/ea040eabe7bac058326174e2cd42dfd9"
},
{
"type": "PACKAGE",
"url": "https://github.com/elysiajs/elysia"
},
{
"type": "WEB",
"url": "https://github.com/elysiajs/elysia/releases/tag/1.4.29"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "elysia has Inefficient Algorithmic Complexity and Interpretation Conflict"
}
GHSA-9F57-9RHG-4HVM
Vulnerability from github – Published: 2025-02-20 03:32 – Updated: 2025-02-20 20:18An issue was discovered in Kwik before 0.10.1. A hash collision vulnerability (in the hash table used to manage connections) allows remote attackers to cause a considerable CPU load on the server (a Hash DoS attack) by initiating connections with colliding Source Connection IDs (SCIDs).
{
"affected": [
{
"package": {
"ecosystem": "Maven",
"name": "tech.kwik:kwik"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.10.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2025-23020"
],
"database_specific": {
"cwe_ids": [
"CWE-407"
],
"github_reviewed": true,
"github_reviewed_at": "2025-02-20T20:18:50Z",
"nvd_published_at": "2025-02-20T03:15:12Z",
"severity": "MODERATE"
},
"details": "An issue was discovered in Kwik before 0.10.1. A hash collision vulnerability (in the hash table used to manage connections) allows remote attackers to cause a considerable CPU load on the server (a Hash DoS attack) by initiating connections with colliding Source Connection IDs (SCIDs).",
"id": "GHSA-9f57-9rhg-4hvm",
"modified": "2025-02-20T20:18:50Z",
"published": "2025-02-20T03:32:03Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-23020"
},
{
"type": "WEB",
"url": "https://github.com/ptrd/kwik/commit/b0733d72bad76bc5d8df2f4a7792ebb2539ebdc8"
},
{
"type": "WEB",
"url": "https://github.com/ncc-pbottine/QUIC-Hash-Dos-Advisory"
},
{
"type": "PACKAGE",
"url": "https://github.com/ptrd/kwik"
},
{
"type": "WEB",
"url": "https://github.com/ptrd/kwik/releases/tag/v0.10.1"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L",
"type": "CVSS_V3"
}
],
"summary": "Kwik hash collision vulnerability"
}
GHSA-9F7V-8M4P-PV76
Vulnerability from github – Published: 2022-05-24 17:03 – Updated: 2024-04-26 09:30knot-resolver before version 4.3.0 is vulnerable to denial of service through high CPU utilization. DNS replies with very many resource records might be processed very inefficiently, in extreme cases taking even several CPU seconds for each such uncached message. For example, a few thousand A records can be squashed into one DNS message (limit is 64kB).
{
"affected": [],
"aliases": [
"CVE-2019-19331"
],
"database_specific": {
"cwe_ids": [
"CWE-404",
"CWE-407"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2019-12-16T16:15:00Z",
"severity": "HIGH"
},
"details": "knot-resolver before version 4.3.0 is vulnerable to denial of service through high CPU utilization. DNS replies with very many resource records might be processed very inefficiently, in extreme cases taking even several CPU seconds for each such uncached message. For example, a few thousand A records can be squashed into one DNS message (limit is 64kB).",
"id": "GHSA-9f7v-8m4p-pv76",
"modified": "2024-04-26T09:30:33Z",
"published": "2022-05-24T17:03:44Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2019-19331"
},
{
"type": "WEB",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2019-19331"
},
{
"type": "WEB",
"url": "https://lists.debian.org/debian-lts-announce/2024/04/msg00017.html"
},
{
"type": "WEB",
"url": "https://www.knot-resolver.cz/2019-12-04-knot-resolver-4.3.0.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-9J65-HCG3-GC64
Vulnerability from github – Published: 2026-10-22 16:38 – Updated: 2026-10-22 16:38Summary
toml.parse() is vulnerable to a quadratic-complexity (O(n²)) denial-of-service via a single
long dotted key, table header, or inline-table key. A ~100KB crafted document causes a
multi-second synchronous hang; a ~200KB document crashes the Node.js process outright with an
uncatchable out-of-memory error. This is a separate, unpatched code path from the previously
fixed stack-overflow DoS (GHSA-82x6-q7mm-w9cf) — it requires no array/inline-table nesting at
all, and is confirmed unaffected by the maxDepth option that fixed that earlier issue.
Affected component / version
- Package:
toml(npm), repositoryBinaryMuse/toml-node - Functions:
assign(),deepRef(),setNestedKey()inlib/compiler.js - Confirmed present in the audited checkout at commit
1b2ac40(2026-07-16), one commit past thev5.0.0tag (a changelog-only change) — i.e. present inv5.0.0, the latest release. Not exhaustively verified against every prior release, but the affected functions are unrelated tov5.0.0's BigInt/Temporal changes (perCHANGELOG.md), so the defect likely predates that release as well.
Details
toml.parse(input, options) (index.js:5-9) forwards the caller-supplied string to
parser.parse() and then compiler.compile() with no length or structural validation.
Inside lib/compiler.js, three separate functions each walk a dotted key's segments in a
for loop and, on every iteration, recompute the full path-prefix string from scratch:
assign()(lines 69-107, the sink at line 81):var intermediatePath = makeFullPath(keys.slice(0, i + 1));— reached for top-level dotted-key assignments likea.b.c = 1.deepRef()(lines 247-281, the sink at line 252): the identical pattern viapathKey(keys.slice(0, i + 1))— reached from table headers[a.b.c]and array-of-tables[[a.b.c]]viasetPath()/addTableArray().setNestedKey()(lines 184-202, the sink at line 187): the identical pattern — reached from inline-table dotted keys liket = { a.b.c = 1 }.
keys.slice(0, i + 1) allocates a new array of length i; pathKey()/makeFullPath()
(lines 311-317) then does .map(quoteDottedString).join("."), also O(i). Since this runs on
every one of the n segments of a dotted key, total work is O(1 + 2 + ... + n) = O(n²), not
O(n). The string is computed unconditionally on the happy path (only ever used if an error
is about to be thrown), so there is no early exit that makes this cheap in practice.
No limit exists anywhere on dotted-key segment count: dot_ended_table_key_part+ and
inline_dot_key_part+ in src/toml.pegjs (lines 122, 311) are unbounded + repetitions,
parsed iteratively rather than through the grammar's value rule — so the existing
MAX_DEPTH/maxDepth nesting guard (src/toml.pegjs:141-151, enforced in the generated
lib/parser.js:1022) does not apply to key length at all. We confirmed this directly: setting
options.maxDepth: 1 (the strictest possible value) against a 16,000-segment key produced no
measurable timing difference from the unrestricted case.
Proof of Concept
const toml = require('toml');
// n-segment dotted key: "k0.k1.k2. ... .k{n-1} = 1"
function segKey(n) {
const parts = [];
for (let i = 0; i < n; i++) parts.push('k' + i);
return parts.join('.') + ' = 1\n';
}
// ~100.9 KB input -- takes ~6.6-6.8 seconds
toml.parse(segKey(16000));
// ~200 KB input -- crashes the Node process:
// "FATAL ERROR: Ineffective mark-compacts near heap limit - JavaScript heap out of memory"
toml.parse(segKey(32000));
Measured timings (Node v22, direct execution against this repo):
| n (segments) | input size | time |
|---|---|---|
| 1,000 | ~4.9 KB | 34 ms |
| 8,000 | ~46.9 KB | 1.6 s |
| 16,000 | ~100.9 KB | 6.8 s |
| 32,000 | ~200 KB | process crash (OOM) |
Doubling n from 8,000→16,000 roughly quadruples runtime (~4.2x), the signature of O(n²)
rather than the expected O(n) (~2x). Independently reproduced with the identical scaling
signature for the table-header variant ([k0. ... .k15999], exercising deepRef()) and the
inline-table variant (t = { k0. ... .k15999 = 1 }, exercising setNestedKey()).
We also generalized this into a property-based fuzzing harness (fast-check, run under Node) that automatically tests the "doubling input size should not more than roughly double parse time" invariant across 12 structural dimensions of the grammar/compiler; it independently re-flags all three code paths above on every run, with no additional dimension confirmed vulnerable after follow-up investigation. The harness is available on request.
Impact
Node.js is single-threaded — a synchronous multi-second-to-crashing parse() call blocks the
entire event loop of the process calling it, stalling every other request/operation that
process is handling, not just the attacker's own. At the upper end this is not merely a hang:
an uncaught, process-terminating out-of-memory crash from a ~200KB attacker-supplied string is
a full denial of service requiring no authentication — just the ability to get one string
parsed by an application using this library (config upload, API request body, imported
manifest, or any of this library's intended use cases).
Suggested remediation
Build the path prefix as an incrementally-extended string as the loop walks each segment
(append one already-quoted segment per iteration to a running string) instead of re-slicing an
array and re-joining the entire prefix from scratch on every iteration. For example, in
assign():
function assign(node) {
var keys = node.key;
var value = node.value;
var off = node.offset;
if (!Array.isArray(keys)) keys = [keys];
var reduced = reduceValueNode(value);
var target = context;
var pathStr = pathKey(currentPath); // computed once, not per segment
for (var i = 0; i < keys.length - 1; i++) {
var k = keys[i];
var quotedK = quoteDottedString(k);
var intermediatePath = pathStr ? pathStr + "." + quotedK : quotedK; // O(new segment), not O(i)
pathStr = intermediatePath;
// ...same conditional logic as today, using intermediatePath
target = target[k];
}
// ...
}
The identical treatment applies to deepRef() and setNestedKey(). As defense-in-depth,
consider also capping total key-segment count or overall input size, the same way maxDepth
already caps nesting.
Credit
Discovered and reported by SecDim Security Research secdim.com | @secdim | security@secdim.com
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 5.0.0"
},
"package": {
"ecosystem": "npm",
"name": "toml"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "5.0.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-114143"
],
"database_specific": {
"cwe_ids": [
"CWE-407"
],
"github_reviewed": true,
"github_reviewed_at": "2026-10-22T16:38:06Z",
"nvd_published_at": "2026-10-21T21:17:56Z",
"severity": "HIGH"
},
"details": "## Summary\n\n`toml.parse()` is vulnerable to a quadratic-complexity (O(n\u00b2)) denial-of-service via a single\nlong dotted key, table header, or inline-table key. A ~100KB crafted document causes a\nmulti-second synchronous hang; a ~200KB document crashes the Node.js process outright with an\nuncatchable out-of-memory error. This is a separate, unpatched code path from the previously\nfixed stack-overflow DoS (`GHSA-82x6-q7mm-w9cf`) \u2014 it requires no array/inline-table nesting at\nall, and is confirmed unaffected by the `maxDepth` option that fixed that earlier issue.\n\n## Affected component / version\n\n- Package: `toml` (npm), repository `BinaryMuse/toml-node`\n- Functions: `assign()`, `deepRef()`, `setNestedKey()` in `lib/compiler.js`\n- Confirmed present in the audited checkout at commit `1b2ac40` (2026-07-16), one commit past\n the `v5.0.0` tag (a changelog-only change) \u2014 i.e. present in `v5.0.0`, the latest release.\n Not exhaustively verified against every prior release, but the affected functions are\n unrelated to `v5.0.0`\u0027s BigInt/Temporal changes (per `CHANGELOG.md`), so the defect likely\n predates that release as well.\n\n## Details\n\n`toml.parse(input, options)` (`index.js:5-9`) forwards the caller-supplied string to\n`parser.parse()` and then `compiler.compile()` with no length or structural validation.\nInside `lib/compiler.js`, three separate functions each walk a dotted key\u0027s segments in a\n`for` loop and, on **every** iteration, recompute the full path-prefix string from scratch:\n\n- `assign()` (lines 69-107, the sink at line 81): `var intermediatePath =\n makeFullPath(keys.slice(0, i + 1));` \u2014 reached for top-level dotted-key assignments like\n `a.b.c = 1`.\n- `deepRef()` (lines 247-281, the sink at line 252): the identical pattern via\n `pathKey(keys.slice(0, i + 1))` \u2014 reached from table headers `[a.b.c]` and array-of-tables\n `[[a.b.c]]` via `setPath()`/`addTableArray()`.\n- `setNestedKey()` (lines 184-202, the sink at line 187): the identical pattern \u2014 reached from\n inline-table dotted keys like `t = { a.b.c = 1 }`.\n\n`keys.slice(0, i + 1)` allocates a new array of length `i`; `pathKey()`/`makeFullPath()`\n(lines 311-317) then does `.map(quoteDottedString).join(\".\")`, also O(i). Since this runs on\nevery one of the `n` segments of a dotted key, total work is `O(1 + 2 + ... + n) = O(n\u00b2)`, not\n`O(n)`. The string is computed unconditionally on the happy path (only ever *used* if an error\nis about to be thrown), so there is no early exit that makes this cheap in practice.\n\nNo limit exists anywhere on dotted-key segment count: `dot_ended_table_key_part+` and\n`inline_dot_key_part+` in `src/toml.pegjs` (lines 122, 311) are unbounded `+` repetitions,\nparsed iteratively rather than through the grammar\u0027s `value` rule \u2014 so the existing\n`MAX_DEPTH`/`maxDepth` nesting guard (`src/toml.pegjs:141-151`, enforced in the generated\n`lib/parser.js:1022`) does not apply to key length at all. We confirmed this directly: setting\n`options.maxDepth: 1` (the strictest possible value) against a 16,000-segment key produced no\nmeasurable timing difference from the unrestricted case.\n\n## Proof of Concept\n\n```js\nconst toml = require(\u0027toml\u0027);\n\n// n-segment dotted key: \"k0.k1.k2. ... .k{n-1} = 1\"\nfunction segKey(n) {\n const parts = [];\n for (let i = 0; i \u003c n; i++) parts.push(\u0027k\u0027 + i);\n return parts.join(\u0027.\u0027) + \u0027 = 1\\n\u0027;\n}\n\n// ~100.9 KB input -- takes ~6.6-6.8 seconds\ntoml.parse(segKey(16000));\n\n// ~200 KB input -- crashes the Node process:\n// \"FATAL ERROR: Ineffective mark-compacts near heap limit - JavaScript heap out of memory\"\ntoml.parse(segKey(32000));\n```\n\nMeasured timings (Node v22, direct execution against this repo):\n\n| n (segments) | input size | time |\n|---|---|---|\n| 1,000 | ~4.9 KB | 34 ms |\n| 8,000 | ~46.9 KB | 1.6 s |\n| 16,000 | ~100.9 KB | 6.8 s |\n| 32,000 | ~200 KB | **process crash (OOM)** |\n\nDoubling `n` from 8,000\u219216,000 roughly quadruples runtime (~4.2x), the signature of O(n\u00b2)\nrather than the expected O(n) (~2x). Independently reproduced with the identical scaling\nsignature for the table-header variant (`[k0. ... .k15999]`, exercising `deepRef()`) and the\ninline-table variant (`t = { k0. ... .k15999 = 1 }`, exercising `setNestedKey()`).\n\nWe also generalized this into a property-based fuzzing harness (fast-check, run under Node)\nthat automatically tests the \"doubling input size should not more than roughly double parse\ntime\" invariant across 12 structural dimensions of the grammar/compiler; it independently\nre-flags all three code paths above on every run, with no additional dimension confirmed\nvulnerable after follow-up investigation. The harness is available on request.\n\n## Impact\n\nNode.js is single-threaded \u2014 a synchronous multi-second-to-crashing `parse()` call blocks the\nentire event loop of the process calling it, stalling every other request/operation that\nprocess is handling, not just the attacker\u0027s own. At the upper end this is not merely a hang:\nan uncaught, process-terminating out-of-memory crash from a ~200KB attacker-supplied string is\na full denial of service requiring no authentication \u2014 just the ability to get one string\nparsed by an application using this library (config upload, API request body, imported\nmanifest, or any of this library\u0027s intended use cases).\n\n## Suggested remediation\n\nBuild the path prefix as an incrementally-extended string as the loop walks each segment\n(append one already-quoted segment per iteration to a running string) instead of re-slicing an\narray and re-joining the entire prefix from scratch on every iteration. For example, in\n`assign()`:\n\n```js\nfunction assign(node) {\n var keys = node.key;\n var value = node.value;\n var off = node.offset;\n if (!Array.isArray(keys)) keys = [keys];\n var reduced = reduceValueNode(value);\n\n var target = context;\n var pathStr = pathKey(currentPath); // computed once, not per segment\n for (var i = 0; i \u003c keys.length - 1; i++) {\n var k = keys[i];\n var quotedK = quoteDottedString(k);\n var intermediatePath = pathStr ? pathStr + \".\" + quotedK : quotedK; // O(new segment), not O(i)\n pathStr = intermediatePath;\n // ...same conditional logic as today, using intermediatePath\n target = target[k];\n }\n // ...\n}\n```\n\nThe identical treatment applies to `deepRef()` and `setNestedKey()`. As defense-in-depth,\nconsider also capping total key-segment count or overall input size, the same way `maxDepth`\nalready caps nesting.\n\n\n## Credit\n\nDiscovered and reported by SecDim Security Research\nsecdim.com | @secdim | security@secdim.com",
"id": "GHSA-9j65-hcg3-gc64",
"modified": "2026-10-22T16:38:06Z",
"published": "2026-10-22T16:38:06Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/BinaryMuse/toml-node/security/advisories/GHSA-9j65-hcg3-gc64"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-114143"
},
{
"type": "WEB",
"url": "https://github.com/BinaryMuse/toml-node/commit/609c873fffea0a27ebe5b4dd098eed2b3daf3606"
},
{
"type": "PACKAGE",
"url": "https://github.com/BinaryMuse/toml-node"
},
{
"type": "WEB",
"url": "https://github.com/BinaryMuse/toml-node/releases/tag/v5.0.1"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N",
"type": "CVSS_V4"
}
],
"summary": "toml-node: Quadratic-complexity DoS via long dotted keys or table paths in toml.parse()"
}
GHSA-9M75-VC3G-4X39
Vulnerability from github – Published: 2026-10-30 23:03 – Updated: 2026-10-30 23:03Summary
In pyasn1 0.6.4 and earlier, decoding a constructed OCTET STRING or character string made of many fragments can spend disproportionate CPU time repeatedly copying the accumulated value. A separate indefinite-length ANY path has the same problem while collecting the encoded components. The work grows roughly quadratically with the number of fixed-size fragments, although the input and decoded value grow linearly. An application that lets an attacker supply such ASN.1 input to an affected decoder can suffer CPU exhaustion.
The affected string paths are available in BER and CER. The DER decoder also accepts certain non-DER constructed strings: a definite-length constructed OCTET STRING when an asn1Spec selects univ.OctetString, and constructed character strings such as UTF8String even without a schema. Indefinite-length ANY is affected in BER and CER when an asn1Spec selects univ.Any; DER rejects indefinite lengths.
This is a distinct decoder path from the OBJECT IDENTIFIER/RELATIVE-OID accumulation addressed by CVE-2026-59885. It has the same complexity class, but the OID fix in 0.6.4 did not change these string or ANY loops.
Technical details
In the v0.6.4 BER decoder, OctetStringPayloadDecoder appends each decoded fragment to a growing bytes value with header += component in both its definite-length and indefinite-length constructed forms. AnyPayloadDecoder.indefLenValueDecoder similarly uses chunk += component. In the exercised paths, each concatenation copies an increasingly large prefix. For N fixed-size fragments, the total copied data grows with 1 + 2 + ... + N, or O(N²).
The OCTET STRING decoder is also the base class of the decoders for UTF8String, NumericString, PrintableString, TeletexString, VideotexString, IA5String, GraphicString, VisibleString, GeneralString, UniversalString, BMPString, ObjectDescriptor, GeneralizedTime, and UTCTime. These types inherit the same constructed-string reassembly path.
The DER decoder's OCTET STRING restriction replaces the tag-driven decoder, but its schema-driven TYPE_MAP retains the BER-derived decoder. Thus der.decode(data) rejects a constructed OCTET STRING, while der.decode(data, asn1Spec=univ.OctetString()) accepts its definite-length form and reaches the accumulation loop. DER does not replace the inherited character-string decoders, so a constructed UTF8String is also accepted without asn1Spec. These inputs violate X.690's DER string-encoding rule and should not be described as valid DER encodings.
The original short-fragment, definite-length OCTET STRING reproducer is valid BER. The CER decoder accepts it, but it is not a conforming CER string encoding: X.690 requires an indefinite-length outer constructed string and 1,000 contents octets per fragment except possibly the last. A conforming CER-shaped constructed OCTET STRING with those fragment sizes also reaches the loop and shows quadratic growth. The indefinite-length ANY reproducer below can represent a CER SEQUENCE OF OCTET STRING and reaches the separate ANY loop when decoded with an ANY schema.
The decoder's eight-octet length-field limit and nesting-depth limit do not bound the number of sibling fragments in these examples. The BER reproducer below uses only a three-octet outer length field; all fragments have shallow nesting. There is no per-message fragment-count cap in v0.6.4.
Impact
If an application passes attacker-controlled ASN.1 to the affected decode() or StreamingDecoder path without an adequate input or resource limit, a megabyte-scale value can occupy a decoding worker for seconds. Repeated inputs can exhaust available CPU. Whether this is reachable before authentication, or through a particular protocol, depends on the application; the library finding alone does not establish those conditions. No confidentiality or integrity impact is claimed.
Severity assessment (CVSS v3.1)
The 7.5 Base score assumes a reasonable application that automatically decodes attacker-supplied ASN.1 from unauthenticated network input. Valid BER and conforming CER inputs trigger the string-reassembly issue without special conditions, privileges, or user interaction. Repeated crafted inputs could occupy all available decoder workers and deny service while the attack continues. No confidentiality or integrity impact is demonstrated. This library-level score does not assert that every adopter has such an endpoint or loses all service; deployment-specific input limits and architecture may change the score. See FIRST's library-scoring guidance.
On the official v0.6.4 tag, local CPU-time measurements with CPython 3.14.8 on macOS arm64 gave the following results. Times vary by machine and Python runtime; the input-size scaling is the relevant observation. “Fixed” means the local 0.6.5 decoder fix applied to the same inputs.
| Decoder path and input | Fragments | v0.6.4 CPU | Fixed CPU |
|---|---|---|---|
| BER constructed OCTET STRING, 0.40 MB | 100,000 × 2 payload bytes | 0.340 s | 0.160 s |
| BER constructed OCTET STRING, 0.80 MB | 200,000 × 2 payload bytes | 0.886 s | 0.312 s |
| BER constructed OCTET STRING, 1.60 MB | 400,000 × 2 payload bytes | 2.738 s | 0.623 s |
BER indefinite ANY, 0.30 MB |
100,000 × 1 payload byte | 0.459 s | 0.206 s |
BER indefinite ANY, 0.60 MB |
200,000 × 1 payload byte | 1.245 s | 0.412 s |
BER indefinite ANY, 1.20 MB |
400,000 × 1 payload byte | 3.980 s | 0.826 s |
| CER constructed OCTET STRING, 1.00 MB, conforming fragment layout | 1,000 × 1,000 payload bytes | 0.0089 s | 0.0022 s |
| CER constructed OCTET STRING, 2.01 MB, conforming fragment layout | 2,000 × 1,000 payload bytes | 0.0311 s | 0.0044 s |
| CER constructed OCTET STRING, 4.02 MB, conforming fragment layout | 4,000 × 1,000 payload bytes | 0.1379 s | 0.0090 s |
For the same short-fragment layout, the original report measured up to 16.05 seconds for a 3.2 MB BER constructed OCTET STRING. An independent report on CPython 3.11.16/Linux measured 5.76 seconds for a 2.4 MB constructed OCTET STRING, versus about 0.005 seconds for a primitive OCTET STRING of comparable size. These are reporter measurements on different systems, not fixed performance guarantees.
Reproduction
This example uses public decoder APIs. Run it with pyasn1 0.6.4 and increase n to observe the scaling. The final two calls show the DER paths accepted by v0.6.4; their constructed encodings are not valid DER.
import time
from pyasn1.codec.ber import decoder as ber
from pyasn1.codec.cer import decoder as cer
from pyasn1.codec.der import decoder as der
from pyasn1.type import univ
def tlv(identifier, contents):
length = len(contents)
if length < 128:
return bytes((identifier, length)) + contents
encoded = length.to_bytes((length.bit_length() + 7) // 8, "big")
return bytes((identifier, 0x80 | len(encoded))) + encoded + contents
def measure(label, decode, substrate, asn1Spec=None):
start = time.process_time()
_, rest = decode(substrate, asn1Spec=asn1Spec)
assert not rest
print(f"{label}: {len(substrate)} input bytes, "
f"{time.process_time() - start:.3f} CPU seconds")
n = 100_000
octet_fragments = b"\x04\x02AA" * n
utf8_fragments = b"\x0c\x02AA" * n
measure("BER constructed OCTET STRING", ber.decode,
tlv(0x24, octet_fragments))
measure("BER indefinite ANY", ber.decode,
b"\x30\x80" + b"\x04\x01A" * n + b"\x00\x00",
univ.Any())
# CER uses indefinite length and 1,000-content-octet primitive fragments.
cer_fragment = tlv(0x04, b"A" * 1000)
measure("CER constructed OCTET STRING", cer.decode,
b"\x24\x80" + cer_fragment * 1000 + b"\x00\x00")
# These constructed encodings are accepted by pyasn1 but are invalid DER.
measure("DER OCTET STRING with schema", der.decode,
tlv(0x24, octet_fragments), univ.OctetString())
measure("DER UTF8String without schema", der.decode,
tlv(0x2c, utf8_fragments))
Patch
pyasn1 0.6.5 replaces the growing bytes accumulator with a list of fragments and joins them once after decoding in all three affected loops. The OCTET STRING base-class change also covers the inheriting character-string decoders. This removes the repeated copying while preserving the assembled decoded value.
Workaround
Until upgrading, enforce application-appropriate limits on the size of untrusted ASN.1 input before passing it to pyasn1, and limit the CPU resources available to decoding workers. Applications that require DER can also reject constructed string encodings before invoking the decoder. The appropriate byte limit depends on the protocol and expected valid values.
Credits and references
Reported by alimony. Independently reported by manus-pi, whose report identified the schema-driven DER route, inherited character-string decoders, and additional performance evidence.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 0.6.4"
},
"package": {
"ecosystem": "PyPI",
"name": "pyasn1"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.6.5"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-119195"
],
"database_specific": {
"cwe_ids": [
"CWE-407"
],
"github_reviewed": true,
"github_reviewed_at": "2026-10-30T23:03:51Z",
"nvd_published_at": "2026-10-29T20:17:30Z",
"severity": "HIGH"
},
"details": "## Summary\n\nIn pyasn1 0.6.4 and earlier, decoding a constructed OCTET STRING or character string made of many fragments can spend disproportionate CPU time repeatedly copying the accumulated value. A separate indefinite-length `ANY` path has the same problem while collecting the encoded components. The work grows roughly quadratically with the number of fixed-size fragments, although the input and decoded value grow linearly. An application that lets an attacker supply such ASN.1 input to an affected decoder can suffer CPU exhaustion.\n\nThe affected string paths are available in BER and CER. The DER decoder also accepts certain *non-DER* constructed strings: a definite-length constructed OCTET STRING when an `asn1Spec` selects `univ.OctetString`, and constructed character strings such as UTF8String even without a schema. Indefinite-length `ANY` is affected in BER and CER when an `asn1Spec` selects `univ.Any`; DER rejects indefinite lengths.\n\nThis is a distinct decoder path from the OBJECT IDENTIFIER/RELATIVE-OID accumulation addressed by [CVE-2026-59885](https://github.com/advisories/GHSA-8ppf-4f7h-5ppj). It has the same complexity class, but the OID fix in 0.6.4 did not change these string or `ANY` loops.\n\n## Technical details\n\nIn the [v0.6.4 BER decoder](https://github.com/pyasn1/pyasn1/blob/v0.6.4/pyasn1/codec/ber/decoder.py), `OctetStringPayloadDecoder` appends each decoded fragment to a growing `bytes` value with `header += component` in both its [definite-length](https://github.com/pyasn1/pyasn1/blob/v0.6.4/pyasn1/codec/ber/decoder.py#L338-L351) and [indefinite-length](https://github.com/pyasn1/pyasn1/blob/v0.6.4/pyasn1/codec/ber/decoder.py#L368-L387) constructed forms. [`AnyPayloadDecoder.indefLenValueDecoder`](https://github.com/pyasn1/pyasn1/blob/v0.6.4/pyasn1/codec/ber/decoder.py#L1403-L1430) similarly uses `chunk += component`. In the exercised paths, each concatenation copies an increasingly large prefix. For `N` fixed-size fragments, the total copied data grows with `1 + 2 + ... + N`, or O(N\u00b2).\n\nThe OCTET STRING decoder is also the base class of the decoders for UTF8String, NumericString, PrintableString, TeletexString, VideotexString, IA5String, GraphicString, VisibleString, GeneralString, UniversalString, BMPString, ObjectDescriptor, GeneralizedTime, and UTCTime. These types inherit the same constructed-string reassembly path.\n\nThe [DER decoder\u0027s OCTET STRING restriction](https://github.com/pyasn1/pyasn1/blob/v0.6.4/pyasn1/codec/der/decoder.py#L15-L49) replaces the tag-driven decoder, but its schema-driven `TYPE_MAP` retains the BER-derived decoder. Thus `der.decode(data)` rejects a constructed OCTET STRING, while `der.decode(data, asn1Spec=univ.OctetString())` accepts its definite-length form and reaches the accumulation loop. DER does not replace the inherited character-string decoders, so a constructed UTF8String is also accepted without `asn1Spec`. These inputs violate [X.690\u0027s DER string-encoding rule](https://www.itu.int/rec/T-REC-X.690-202102-I/en) and should not be described as valid DER encodings.\n\nThe original short-fragment, definite-length OCTET STRING reproducer is valid BER. The CER decoder accepts it, but it is not a conforming CER string encoding: X.690 requires an indefinite-length outer constructed string and 1,000 contents octets per fragment except possibly the last. A conforming CER-shaped constructed OCTET STRING with those fragment sizes also reaches the loop and shows quadratic growth. The indefinite-length `ANY` reproducer below can represent a CER `SEQUENCE OF OCTET STRING` and reaches the separate `ANY` loop when decoded with an `ANY` schema.\n\nThe decoder\u0027s eight-octet length-field limit and nesting-depth limit do not bound the number of sibling fragments in these examples. The BER reproducer below uses only a three-octet outer length field; all fragments have shallow nesting. There is no per-message fragment-count cap in v0.6.4.\n\n## Impact\n\nIf an application passes attacker-controlled ASN.1 to the affected `decode()` or `StreamingDecoder` path without an adequate input or resource limit, a megabyte-scale value can occupy a decoding worker for seconds. Repeated inputs can exhaust available CPU. Whether this is reachable before authentication, or through a particular protocol, depends on the application; the library finding alone does not establish those conditions. No confidentiality or integrity impact is claimed.\n\n## Severity assessment (CVSS v3.1)\n\nThe 7.5 Base score assumes a reasonable application that automatically decodes attacker-supplied ASN.1 from unauthenticated network input. Valid BER and conforming CER inputs trigger the string-reassembly issue without special conditions, privileges, or user interaction. Repeated crafted inputs could occupy all available decoder workers and deny service while the attack continues. No confidentiality or integrity impact is demonstrated. This library-level score does not assert that every adopter has such an endpoint or loses all service; deployment-specific input limits and architecture may change the score. See [FIRST\u0027s library-scoring guidance](https://www.first.org/cvss/v3-1/user-guide).\n\nOn the official v0.6.4 tag, local CPU-time measurements with CPython 3.14.8 on macOS arm64 gave the following results. Times vary by machine and Python runtime; the input-size scaling is the relevant observation. \u201cFixed\u201d means the local 0.6.5 decoder fix applied to the same inputs.\n\n| Decoder path and input | Fragments | v0.6.4 CPU | Fixed CPU |\n| --- | ---: | ---: | ---: |\n| BER constructed OCTET STRING, 0.40 MB | 100,000 \u00d7 2 payload bytes | 0.340 s | 0.160 s |\n| BER constructed OCTET STRING, 0.80 MB | 200,000 \u00d7 2 payload bytes | 0.886 s | 0.312 s |\n| BER constructed OCTET STRING, 1.60 MB | 400,000 \u00d7 2 payload bytes | 2.738 s | 0.623 s |\n| BER indefinite `ANY`, 0.30 MB | 100,000 \u00d7 1 payload byte | 0.459 s | 0.206 s |\n| BER indefinite `ANY`, 0.60 MB | 200,000 \u00d7 1 payload byte | 1.245 s | 0.412 s |\n| BER indefinite `ANY`, 1.20 MB | 400,000 \u00d7 1 payload byte | 3.980 s | 0.826 s |\n| CER constructed OCTET STRING, 1.00 MB, conforming fragment layout | 1,000 \u00d7 1,000 payload bytes | 0.0089 s | 0.0022 s |\n| CER constructed OCTET STRING, 2.01 MB, conforming fragment layout | 2,000 \u00d7 1,000 payload bytes | 0.0311 s | 0.0044 s |\n| CER constructed OCTET STRING, 4.02 MB, conforming fragment layout | 4,000 \u00d7 1,000 payload bytes | 0.1379 s | 0.0090 s |\n\nFor the same short-fragment layout, the original report measured up to 16.05 seconds for a 3.2 MB BER constructed OCTET STRING. An independent report on CPython 3.11.16/Linux measured 5.76 seconds for a 2.4 MB constructed OCTET STRING, versus about 0.005 seconds for a primitive OCTET STRING of comparable size. These are reporter measurements on different systems, not fixed performance guarantees.\n\n## Reproduction\n\nThis example uses public decoder APIs. Run it with pyasn1 0.6.4 and increase `n` to observe the scaling. The final two calls show the DER paths accepted by v0.6.4; their constructed encodings are not valid DER.\n\n```python\nimport time\n\nfrom pyasn1.codec.ber import decoder as ber\nfrom pyasn1.codec.cer import decoder as cer\nfrom pyasn1.codec.der import decoder as der\nfrom pyasn1.type import univ\n\n\ndef tlv(identifier, contents):\n length = len(contents)\n if length \u003c 128:\n return bytes((identifier, length)) + contents\n encoded = length.to_bytes((length.bit_length() + 7) // 8, \"big\")\n return bytes((identifier, 0x80 | len(encoded))) + encoded + contents\n\n\ndef measure(label, decode, substrate, asn1Spec=None):\n start = time.process_time()\n _, rest = decode(substrate, asn1Spec=asn1Spec)\n assert not rest\n print(f\"{label}: {len(substrate)} input bytes, \"\n f\"{time.process_time() - start:.3f} CPU seconds\")\n\n\nn = 100_000\noctet_fragments = b\"\\x04\\x02AA\" * n\nutf8_fragments = b\"\\x0c\\x02AA\" * n\n\nmeasure(\"BER constructed OCTET STRING\", ber.decode,\n tlv(0x24, octet_fragments))\nmeasure(\"BER indefinite ANY\", ber.decode,\n b\"\\x30\\x80\" + b\"\\x04\\x01A\" * n + b\"\\x00\\x00\",\n univ.Any())\n\n# CER uses indefinite length and 1,000-content-octet primitive fragments.\ncer_fragment = tlv(0x04, b\"A\" * 1000)\nmeasure(\"CER constructed OCTET STRING\", cer.decode,\n b\"\\x24\\x80\" + cer_fragment * 1000 + b\"\\x00\\x00\")\n\n# These constructed encodings are accepted by pyasn1 but are invalid DER.\nmeasure(\"DER OCTET STRING with schema\", der.decode,\n tlv(0x24, octet_fragments), univ.OctetString())\nmeasure(\"DER UTF8String without schema\", der.decode,\n tlv(0x2c, utf8_fragments))\n```\n\n## Patch\n\npyasn1 0.6.5 replaces the growing `bytes` accumulator with a list of fragments and joins them once after decoding in all three affected loops. The OCTET STRING base-class change also covers the inheriting character-string decoders. This removes the repeated copying while preserving the assembled decoded value.\n\n## Workaround\n\nUntil upgrading, enforce application-appropriate limits on the size of untrusted ASN.1 input *before* passing it to pyasn1, and limit the CPU resources available to decoding workers. Applications that require DER can also reject constructed string encodings before invoking the decoder. The appropriate byte limit depends on the protocol and expected valid values.\n\n## Credits and references\n\nReported by [alimony](https://github.com/alimony). Independently reported by [manus-pi](https://github.com/manus-pi), whose report identified the schema-driven DER route, inherited character-string decoders, and additional performance evidence.\n\n- [pyasn1 v0.6.4 affected decoder source](https://github.com/pyasn1/pyasn1/blob/v0.6.4/pyasn1/codec/ber/decoder.py)\n- [ITU-T X.690, CER and DER string-encoding rules](https://www.itu.int/rec/T-REC-X.690-202102-I/en)\n- [CVE-2026-59885, separate OID decoder issue](https://github.com/advisories/GHSA-8ppf-4f7h-5ppj)",
"id": "GHSA-9m75-vc3g-4x39",
"modified": "2026-10-30T23:03:51Z",
"published": "2026-10-30T23:03:51Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/pyasn1/pyasn1/security/advisories/GHSA-9m75-vc3g-4x39"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-119195"
},
{
"type": "WEB",
"url": "https://github.com/pyasn1/pyasn1/pull/132"
},
{
"type": "WEB",
"url": "https://github.com/pyasn1/pyasn1/commit/4ce00797c594b59c1fd6b86d9ebc3ba87b7ec9f9"
},
{
"type": "PACKAGE",
"url": "https://github.com/pyasn1/pyasn1"
},
{
"type": "WEB",
"url": "https://github.com/pyasn1/pyasn1/releases/tag/v0.6.5"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "pyasn1 has quadratic-time denial of service in constructed string and indefinite-length ANY decoding"
}
GHSA-9M86-7PMV-2852
Vulnerability from github – Published: 2026-03-02 22:03 – Updated: 2026-03-06 21:56Impact
An attacker who uses this vulnerability can craft a PDF which leads to long runtimes. This requires accessing a stream which uses the /ASCIIHexDecode filter.
Patches
This has been fixed in pypdf==6.7.5.
Workarounds
If you cannot upgrade yet, consider applying the changes from PR #3666.
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "pypdf"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "6.7.5"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-28804"
],
"database_specific": {
"cwe_ids": [
"CWE-407"
],
"github_reviewed": true,
"github_reviewed_at": "2026-03-02T22:03:45Z",
"nvd_published_at": "2026-03-06T07:16:01Z",
"severity": "MODERATE"
},
"details": "### Impact\nAn attacker who uses this vulnerability can craft a PDF which leads to long runtimes. This requires accessing a stream which uses the `/ASCIIHexDecode` filter.\n\n### Patches\nThis has been fixed in [pypdf==6.7.5](https://github.com/py-pdf/pypdf/releases/tag/6.7.5).\n\n### Workarounds\nIf you cannot upgrade yet, consider applying the changes from PR [#3666](https://github.com/py-pdf/pypdf/pull/3666).",
"id": "GHSA-9m86-7pmv-2852",
"modified": "2026-03-06T21:56:41Z",
"published": "2026-03-02T22:03:45Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/py-pdf/pypdf/security/advisories/GHSA-9m86-7pmv-2852"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-28804"
},
{
"type": "WEB",
"url": "https://github.com/py-pdf/pypdf/pull/3666"
},
{
"type": "WEB",
"url": "https://github.com/py-pdf/pypdf/commit/648c627d2657447dfb1773412af05a0a5103b98f"
},
{
"type": "PACKAGE",
"url": "https://github.com/py-pdf/pypdf"
},
{
"type": "WEB",
"url": "https://github.com/py-pdf/pypdf/releases/tag/6.7.5"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N",
"type": "CVSS_V4"
}
],
"summary": "pypdf vulnerable to inefficient decoding of ASCIIHexDecode streams"
}
No mitigation information available for this CWE.
No CAPEC attack patterns related to this CWE.