BREW-ADR-VIEWER-CVE-2026-97698 (GHSA-PHMP-HRW4-R36R)

Vulnerability from osv_homebrew – Published: 2026-11-21 10:57 – Updated: 2026-11-21 10:57 – Source website
VLAI
Summary
Mistune: Quadratic-time DoS in parse_link_href via unbounded parenthesis scan on empty-label links
Details

Resolution

Fixed in Mistune 3.3.4. Upgrade to 3.3.4 or later.

  • Affected versions: < 3.3.4
  • First patched version: 3.3.4
  • Fix: https://github.com/lepture/mistune/compare/v3.3.3...v3.3.4

The reported payload was reproduced against the 3.3.3 release tag and verified to scale approximately linearly against the 3.3.4 release tag.

Original report

The following report describes the issue before the fix.

Summary

parse_link_href in mistune performs an unbounded parenthesis-balancing scan that runs to end-of-document on each unmatched (. Because the empty label [] bypasses the no_close_bracket_before high-water-mark guard, a single small document of the form "[](" * N causes O(N) openers to each drive an O(N) scan, producing O(N²) CPU on the default mistune.html() renderer with no plugins.

Root Cause

parse_link matches the empty label [] (parse_link_label("[](",1) returns ('', 2)), so it reaches the ( branch and calls parse_link_href. That function's scan loop (helpers.py:143-159) advances past characters and increments level on each (, never finding an unescaped ) at level==0, so it runs to EOF and returns None. The cursor then advances only ~2 chars to the next [](. The no_close_bracket_before high-water mark that keeps the balanced-bracket link path linear is never entered because the empty label matches before that branch; _mark_no_link_before only advances past the 2-char label, not the href region.

Impact

A single unauthenticated request rendering untrusted markdown pins a worker at 100% CPU for tens of seconds. Measured on default mistune.html, no plugins: 6KB->0.80s, 12KB->3.15s, 24KB->12.5s, 48KB->49.8s (2x input -> ~3.9x time, clean O(n²)). This is the most severe of the mistune quadratic-DoS findings.

Proof of Concept

import mistune
md = mistune.create_markdown()   # default HTML renderer, no plugins
md("[](" * 16000)                # ~48KB input stalls a worker ~50s

Attack Chain

  1. Entry: rendered markdown body -> "[](" * N (3 bytes/unit, no plugins). Guard: none on input size (grep of markdown.py/core.py = no size/time cap). Bypass proof: no global guard exists.
  2. Check: parse_link guards at inline_parser.py:141 (no_link_before), :150 (no_close_bracket_before). Guard: high-water marks that linearize balanced-bracket links. Bypass proof: empty label matches (label != None) so the :150 branch is skipped entirely; no_link_before only crawls +2/opener because parse_link_label returns ('',2).
  3. Processing: parse_link_href (helpers.py:143) scans to EOF per ( (unbalanced parens), returns None.
  4. Sink: O(N) openers x O(N) scan each -> O(N²) CPU.
  5. Impact: single ~48KB request stalls a worker ~50s (single-threaded); ~200KB approx minutes.

Bypass Evidence

  • parse_link_label("[](",1) returns ('', 2) — the empty label matches, so the balanced-bracket branch owning no_close_bracket_before is never entered.
  • git log -S "if c == \"(\":" -- helpers.py returns only refactor 5de41fb; parse_link_href has NEVER received a DoS fix (all helpers.py DoS fixes targeted parse_link_text).
  • Empirical: the [n unbalanced-bracket payload is LINEAR on HEAD (0.03->0.12s) while [](n is O(n²) (3.99x per 2x) — proving the fix does not cover this branch.

Affected Versions

<= 3.3.3 (present on latest release tag v3.3.3 and HEAD 719107f; no fix on HEAD).

Suggested Fix

Add a high-water mark for parse_link_href failed scans (mirroring no_link_before/no_close_bracket_before), or bound the parenthesis scan to a maximum length, so repeated failed href scans cannot each traverse the remaining document.


Reported by zx (Jace) — GitHub: @manus-use

Impacted products
Ecosystem Package Version
Homebrew adr-viewer
pkg:brew/adr-viewer
Affected: ≥ 1.3.0, < 1.4.0_7 (ecosystem)

{
  "affected": [
    {
      "ecosystem_specific": {
        "fix": "bump",
        "range_state": "fixed",
        "resource": "mistune",
        "resource_purl": "pkg:pypi/mistune@3.4.0",
        "upstream_fixed_in": "3.3.4"
      },
      "package": {
        "ecosystem": "Homebrew",
        "name": "adr-viewer",
        "purl": "pkg:brew/adr-viewer"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "1.3.0"
            },
            {
              "fixed": "1.4.0_7"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "database_specific": {
    "confidence": "high",
    "source": "matched",
    "strategy": "registry",
    "upstream_evidence": [
      {
        "ecosystem": "PyPI",
        "key": "pkg:pypi/mistune@3.4.0",
        "name": "mistune",
        "resource": "mistune",
        "strategy": "registry",
        "subject_version": "3.4.0"
      }
    ]
  },
  "details": "## Resolution\n\n**Fixed in Mistune 3.3.4.** Upgrade to 3.3.4 or later.\n\n- Affected versions: `\u003c 3.3.4`\n- First patched version: `3.3.4`\n- Fix: https://github.com/lepture/mistune/compare/v3.3.3...v3.3.4\n\nThe reported payload was reproduced against the 3.3.3 release tag and verified to scale approximately linearly against the 3.3.4 release tag.\n\n## Original report\n\nThe following report describes the issue before the fix.\n\n## Summary\n`parse_link_href` in mistune performs an unbounded parenthesis-balancing scan that runs to end-of-document on each unmatched `(`. Because the empty label `[]` bypasses the `no_close_bracket_before` high-water-mark guard, a single small document of the form `\"[](\" * N` causes O(N) openers to each drive an O(N) scan, producing O(N\u00b2) CPU on the **default** `mistune.html()` renderer with no plugins.\n\n## Root Cause\n`parse_link` matches the empty label `[]` (`parse_link_label(\"[](\",1)` returns `(\u0027\u0027, 2)`), so it reaches the `(` branch and calls `parse_link_href`. That function\u0027s scan loop (helpers.py:143-159) advances past characters and increments `level` on each `(`, never finding an unescaped `)` at `level==0`, so it runs to EOF and returns `None`. The cursor then advances only ~2 chars to the next `[](`. The `no_close_bracket_before` high-water mark that keeps the balanced-bracket link path linear is never entered because the empty label matches before that branch; `_mark_no_link_before` only advances past the 2-char label, not the href region.\n\n## Impact\nA single unauthenticated request rendering untrusted markdown pins a worker at 100% CPU for tens of seconds. Measured on default `mistune.html`, no plugins: 6KB-\u003e0.80s, 12KB-\u003e3.15s, 24KB-\u003e12.5s, 48KB-\u003e49.8s (2x input -\u003e ~3.9x time, clean O(n\u00b2)). This is the most severe of the mistune quadratic-DoS findings.\n\n## Proof of Concept\n```python\nimport mistune\nmd = mistune.create_markdown()   # default HTML renderer, no plugins\nmd(\"[](\" * 16000)                # ~48KB input stalls a worker ~50s\n```\n\n## Attack Chain\n1. Entry: rendered markdown body -\u003e `\"[](\" * N` (3 bytes/unit, no plugins). Guard: none on input size (grep of markdown.py/core.py = no size/time cap). Bypass proof: no global guard exists.\n2. Check: `parse_link` guards at inline_parser.py:141 (`no_link_before`), :150 (`no_close_bracket_before`). Guard: high-water marks that linearize balanced-bracket links. Bypass proof: empty label matches (label != None) so the :150 branch is skipped entirely; `no_link_before` only crawls +2/opener because `parse_link_label` returns `(\u0027\u0027,2)`.\n3. Processing: `parse_link_href` (helpers.py:143) scans to EOF per `(` (unbalanced parens), returns `None`.\n4. Sink: O(N) openers x O(N) scan each -\u003e O(N\u00b2) CPU.\n5. Impact: single ~48KB request stalls a worker ~50s (single-threaded); ~200KB approx minutes.\n\n## Bypass Evidence\n- `parse_link_label(\"[](\",1)` returns `(\u0027\u0027, 2)` \u2014 the empty label matches, so the balanced-bracket branch owning `no_close_bracket_before` is never entered.\n- `git log -S \"if c == \\\"(\\\":\" -- helpers.py` returns only refactor `5de41fb`; `parse_link_href` has NEVER received a DoS fix (all helpers.py DoS fixes targeted `parse_link_text`).\n- Empirical: the `[`*n unbalanced-bracket payload is LINEAR on HEAD (0.03-\u003e0.12s) while `[](`*n is O(n\u00b2) (3.99x per 2x) \u2014 proving the fix does not cover this branch.\n\n## Affected Versions\n`\u003c= 3.3.3` (present on latest release tag v3.3.3 and HEAD `719107f`; no fix on HEAD).\n\n## Suggested Fix\nAdd a high-water mark for `parse_link_href` failed scans (mirroring `no_link_before`/`no_close_bracket_before`), or bound the parenthesis scan to a maximum length, so repeated failed href scans cannot each traverse the remaining document.\n\n---\nReported by **zx (Jace)** \u2014 GitHub: @manus-use",
  "id": "BREW-adr-viewer-CVE-2026-97698",
  "modified": "2026-11-21T10:57:41Z",
  "published": "2026-11-21T10:57:41Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/lepture/mistune/security/advisories/GHSA-phmp-hrw4-r36r"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-97698"
    },
    {
      "type": "WEB",
      "url": "https://github.com/lepture/mistune/commit/b4dd3284e52ec741ed9a227db29ade9017828e90"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/lepture/mistune"
    },
    {
      "type": "WEB",
      "url": "https://github.com/lepture/mistune/releases/tag/v3.3.4"
    }
  ],
  "schema_version": "1.7.3",
  "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": "Mistune: Quadratic-time DoS in parse_link_href via unbounded parenthesis scan on empty-label links",
  "upstream": [
    "GHSA-phmp-hrw4-r36r",
    "CVE-2026-97698"
  ]
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline

Sightings and recorded dates, grouped by day · UTC

JSON
How durations are calculated

Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation.

Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.

Events included in the timeline

Loading timeline…


    Loading…

    Loading…

    Loading…

    Related by attack behaviour

    Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.