# Super-linear parser complexity DoS

Per-token work that grows with input size: weak-hash buckets, failed terminator lookups, repeated reference tokens

_Area: Web business logic and race conditions. Seen in 3 disclosed reports; one confirmed bounty: $7,640; latest 2026-09-08. Updated 2026-11-14._

## How it works
A parser, hasher or renderer does work per input token that itself scales with input size, so total cost grows faster than the input (quadratic or worse). The broken assumption is that each token is handled in constant time. It breaks when a hash bucket degenerates to one long chain, a terminator search fails and returns `-1`, or a reference extractor re-scans accumulated text for every repeated token. A small crafted input then burns CPU far out of proportion to its size [E1](https://bugbountylibrary.com/r/h1%3A1341957.md)[E2](https://bugbountylibrary.com/r/h1%3A1543718.md)[E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-6mj3-qw4j-hgrw.md).

## Where it shows up
- Hash tables that compare entries by hash value only, or allow duplicate keys, so many keys chain into one bucket [E1](https://bugbountylibrary.com/r/h1%3A1341957.md)
- Terminator searches (`indexOf`, regex) that are case-sensitive where the spec requires case-insensitive matching, leaving a `-1` result [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-6mj3-qw4j-hgrw.md)
- Unguarded `substring`/slice whose end index derives from a `-1` lookup, feeding a parse loop [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-6mj3-qw4j-hgrw.md)
- Reference/link extractors that accumulate text and re-render a collection per repeated token like `![` or `[` [E2](https://bugbountylibrary.com/r/h1%3A1543718.md)
- Autolink scanning across long runs of unterminated openers (mechanism inferred from the advisory, not stated) [E4]

## How to review
Find every loop over input tokens and ask: is the per-token work bounded by a constant, independent of total input length? The invariant is that total cost is linear in input size. Check that terminator lookups match the spec's case rules and that a failed lookup (`-1`) is handled before any slice or loop uses it [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-6mj3-qw4j-hgrw.md). For hash tables, confirm keys are compared fully, not by hash alone, and that duplicate inserts are rejected or bounded [E1](https://bugbountylibrary.com/r/h1%3A1341957.md). For renderers, confirm reference extraction does not re-scan accumulated text per token [E2](https://bugbountylibrary.com/r/h1%3A1543718.md). Trace request-controlled data (headers, body, markdown) into any parser and measure cost on maximal repeated-token input.

## How finders spotted it
- Read the parser source, saw the reference table used a weak hash with chaining and hash-only equality, reasoned lookups become O(N), then crafted inputs sharing bucket index (hash % table size) rather than full collisions, since full collisions short-circuit in O(1) [E1](https://bugbountylibrary.com/r/h1%3A1341957.md)
- Inspected the preview code path, noticed `analyze` accumulates `texts_and_contexts` and `cache_collection_render` runs in the reference extractor, hypothesized repeated reference-like tokens blow up cost, confirmed with maximal-size input [E2](https://bugbountylibrary.com/r/h1%3A1543718.md)
- Noticed the raw-text close-tag search used case-sensitive `indexOf` against the WHATWG case-insensitive rule, traced the `-1` through the unguarded substring and parse-loop fallback to derive O(n²); also checked which versions shared the flaw [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-6mj3-qw4j-hgrw.md)

## Variants seen
- Weak-hash bucket collision in a markdown reference table [E1](https://bugbountylibrary.com/r/h1%3A1341957.md)
- Quadratic reference extraction in a preview renderer [E2](https://bugbountylibrary.com/r/h1%3A1543718.md)
- Case-mismatch terminator causing output amplification in an HTML parser [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-6mj3-qw4j-hgrw.md)
- Polynomial autolink scanning in cmark-gfm (mechanism inferred, not stated) [E4]
- Out of scope for this pattern: regex backtracking (ReDoS) in a Time parser reached via HTTP headers — a distinct mechanism, not token-scaling [E4]

## Impact and severity
CPU exhaustion leading to denial of service; severity rises when the endpoint is unauthenticated [E4] or reachable on a shared instance, where parallel requests scale single-core burn to full-server DoS and DDoS potential [E2](https://bugbountylibrary.com/r/h1%3A1543718.md).

## Seen in real software
Open-source packages and projects, and products, where this pattern was found. If the target runs one, compare the version it runs with the fix.
- **@xmldom/xmldom (npm)** >= 0.9.0-beta.1, <= 0.9.11, fixed in 0.9.12: xmldom: HTML raw-text closing-tag case mismatch causes output amplification (CVE-2026-83612). Report: https://bugbountylibrary.com/r/ghsa%3AGHSA-6mj3-qw4j-hgrw.md. Fix: https://github.com/xmldom/xmldom/commit/7ced40c06c28d151e996a97045018c3559ae4707
- **GitLab**: DOS via issue preview. Report: https://bugbountylibrary.com/r/h1%3A1543718.md

## Evidence
- E1: https://bugbountylibrary.com/r/h1%3A1341957.md
- E2: https://bugbountylibrary.com/r/h1%3A1543718.md
- E3: https://bugbountylibrary.com/r/ghsa%3AGHSA-6mj3-qw4j-hgrw.md
