Skip to content

Update dependency markdown-it to v14 [SECURITY] - #1884

Open
renovate[bot] wants to merge 1 commit into
master-devfrom
renovate/npm-markdown-it-vulnerability
Open

renovate[bot] wants to merge 1 commit into
master-devfrom
renovate/npm-markdown-it-vulnerability

Conversation

@renovate

@renovate renovate Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Confidence
markdown-it 12.3.2 → 14.3.1 age confidence

markdown-it: Quadratic complexity DoS in smartquotes rule via replaceAt string operations

CVE-2026-48988 / GHSA-6v5v-wf23-fmfq

More information

Details

Summary

A quadratic time complexity vulnerability exists in markdown-it's smartquotes rule (enabled via the typographer: true option). An attacker can craft a markdown input consisting of consecutive quotation marks that causes the parser to consume excessive CPU time, leading to denial of service.

Details

The vulnerability is in the replaceAt() helper function used by the smartquotes rule in lib/rules_core/smartquotes.mjs:

function replaceAt (str, index, ch) {
  return str.slice(0, index) + ch + str.slice(index + 1)
}

When markdown-it processes a text token containing many quotation marks (either " or ') with typographer: true, the smartquotes rule iterates through each quote character and calls replaceAt() to substitute it with a typographic (curly) quote. Each call to replaceAt() creates three new string slices and concatenates them, which is an O(n) operation where n is the length of the string.

Since this is called once per quote character in the token, and there are n quote characters, the total time complexity becomes O(n^2).

The root cause is that the smartquotes rule modifies token.content in place using string slicing rather than building the result incrementally. The process_inlines() function (line 14) processes each quote in the text token, and for matching quote pairs, calls replaceAt() on both the opening and closing token's content (lines 151-152). When the entire input is a single text token of quote characters, this results in quadratic behavior.

PoC
const md = require('markdown-it');
const instance = md({ typographer: true });

// 160,000 consecutive double-quote characters
const payload = '"'.repeat(160000);

console.time('render');
instance.render(payload);
console.timeEnd('render');
// Output: render: ~21000ms (21 seconds)

// Compare with typographer disabled:
const safe = md({ typographer: false });
console.time('render-safe');
safe.render(payload);
console.timeEnd('render-safe');
// Output: render-safe: ~8ms

Measured timing on a modern system:

  • 10,000 quotes: ~19ms
  • 20,000 quotes: ~51ms
  • 40,000 quotes: ~212ms
  • 80,000 quotes: ~5,430ms
  • 160,000 quotes: ~21,198ms

The scaling is clearly superlinear (quadratic), with the 80K->160K step showing a ~3.9x increase for a 2x input increase, consistent with O(n^2).

Impact

Applications that render user-supplied markdown with typographer: true are vulnerable to denial of service. An attacker can submit a relatively small payload (160KB of quote characters) that causes the server to spend over 21 seconds processing a single request. Repeated submissions can exhaust server CPU resources and prevent legitimate users from being served.

The impact is mitigated by the fact that the typographer option defaults to false and must be explicitly enabled. However, the typographer feature is commonly enabled in production applications that want smart typography, and the markdown-it documentation prominently suggests enabling it.

A suggested fix would be to replace the replaceAt() approach with an array-based or StringBuilder-style approach that collects all replacements and applies them in a single pass, reducing the time complexity to O(n).

Severity

  • CVSS Score: 5.3 / 10 (Medium)
  • Vector String: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


markdown-it linkify: true has two quadratic paths, so a few hundred KB of markdown blocks the event loop for tens of seconds

GHSA-253c-mchw-3w2r

More information

Details

Summary

Two independent quadratic paths in the linkify: true handling. Both are in markdown-it's own code rather than in linkify-it, which stays linear on both payloads.

src/rules_core/linkify.ts calls arrayReplaceAt once per linkified text token, and that rebuilds the whole children array each time. A paragraph of N soft-broken lines is one inline token with about 2N children, so you get N rebuilds over a 2N array. Schema-less emails are what reach it. A http:// link gets consumed by the inline rule first and never arrives as a text token, so those stay linear.

src/rules_inline/linkify.ts runs state.pending.match(SCHEME_RE) at every :// in the source. state.pending only gets truncated once a link is actually produced, so an unregistered scheme leaves it growing and every :// rescans the lot.

Proof of concept

Clean install of 15.0.0 from npm, new MarkdownIt({ linkify: true }).render(payload), Node 24.

N 5,000 10,000 20,000 40,000
'a@b.co\n'.repeat(N), 34KB to 273KB 1.1s 4.7s 19.6s 89s
'a://'.repeat(N), 20KB to 156KB 0.25s 0.76s 3.1s 15.0s

Doubling the input roughly quadruples the time in both. With linkify: false the same inputs run in 25 to 131ms and stay flat.

Controls for the first one, all at N=20000: putting every email in a single text token ('a@b.co ') takes 0.59s, one email per paragraph ('a@b.co\n\n') takes 0.64s, and soft-broken lines with nothing linkifiable take 42ms. So it needs many children AND many of them linkifying. For the second, replaying just the SCHEME_RE calls against the same growing prefixes with no markdown-it involved accounts for 11.7s of the 15s.

Ordinary prose does it too. 'ping a@b.co ok\n'.repeat(20000) is 293KB and takes 31s.

Caveat

linkify is off by default, so this only reaches apps that turn it on.

Impact

Availability only. A few hundred KB of fairly ordinary markdown pins one core for tens of seconds, and because it's quadratic it degrades quickly with size. Nothing is read, written or executed.

Severity

  • CVSS Score: 6.3 / 10 (Medium)
  • Vector String: CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Release Notes

markdown-it/markdown-it (markdown-it)

v14.3.1

Compare Source

v14.3.0

Compare Source

Changed
  • Reworked build pipeline & tools.
  • Added source maps.
  • Bumped linkify-it to 5.0.2.
Fixed
  • Preserve backslash-space hard line breaks, matching CommonMark 6.7, #​1185.

v14.2.0

Compare Source

Added
  • isPunctCharCode to utilities.
Fixed
  • Don't end HTML comment blocks on a blank line, #​1155.
  • Properly recognize astral chars (surrogates) in delimiter scans for
    emphasis-like markers, #​1072. Big thanks to @​tats-u for his global efforts
    with improving CJK support.
  • Preserve unicode whitespaces when trimm headings/paragraphs, #​1074.
  • More strict entities decode to avoid false positives ;, #​1096.
  • Restore block parser state on fail in lheading rule, #​1131.
Security
  • Fixed poor smartquotes perfomance on > 70k quotes in single block
  • Bumped linkify-it to 5.0.1 with fixed potential perfomance issues.

v14.1.1

Compare Source

Security
  • Fixed regression from v13 in linkify inline rule. Specific patterns could
    cause high CPU use. Thanks to @​ltduc147 for report.

v14.1.0

Compare Source

Changed
  • Updated CM spec compatibility to 0.31.2, #​1009.
Fixed
  • Fixed quadratic complexity when parsing references, #​996.
  • Fixed quadratic output size with pathological user input in tables, #​1000.

v14.0.0

Compare Source

Changed
  • Drop ancient browsers support (use .fromCodePoint and other features).
  • Rewrite to ESM (including all plugins/deps). CJS fallback still available.
    No signatures changed, except markdown-it-emoji plugin.
  • Dropped dist/ folder from repo, build on package publish.
  • Set punicode.js as external dependency.
Fixed
  • Html tokens inside img alt are now rendered as their original text, #​896.
  • Hardbreaks inside img alt are now rendered as newlines.

v13.0.2

Compare Source

Security
  • Fixed crash/infinite loop caused by linkify inline rule, #​957.
Fixed
  • Throw an error if 3rd party plugin doesn't increment line or pos counters
    (previously, markdown-it would likely go into infinite loop instead), #​847.

v13.0.1

Compare Source

Fixed
  • Bumped linkify-it to 4.0.1. That should fix some hangs, caused by wrong
    data, returned from linkify-it.

v13.0.0

Compare Source

Added
  • Added a new token type text_special to store escaped characters, same as text but
    unaffected by replacement plugins (smartquotes, typographer, linkifier, etc.).
  • Added a new rule text_join in core ruler. Text replacement plugins may choose to
    insert themselves before it.
Changed
  • (p) is no longer replaced with § by typographer (conflicts with ℗), #​763.
  • text_collapse rule is renamed to fragments_join.
Fixed
  • Smartquotes, typographic replacements and plain text links can now be escaped
    with backslash (e.g. \(c) or google\.com are no longer replaced).
  • Fixed collision of emphasis and linkifier (so http://example.org/foo._bar_-_baz
    is now a single link, not emphasized). Emails and fuzzy links are not affected by this.

Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate Bot added dependencies Pull requests that update a dependency file security labels Aug 26, 2026
@renovate

renovate Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor Author

⚠️ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: zapisy/yarn.lock
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 0.41s
➤ YN0000: ┌ Fetch step
➤ YN0001: │ TypeError: fsevents@patch:fsevents@npm%3A1.2.13#builtin<compat/fsevents>::version=1.2.13&hash=87eb42: (0 , A.isDate) is not a function
    at /tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:419607
    at C.utimesImpl (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:419666)
    at C.utimesSync (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:419065)
    at C.utimesPromise (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:418931)
    at C.mkdirpPromise (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:383563)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async z.fetchers.patchPackage (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:217976)
    at async Q (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:244809)
    at async v (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:245268)
    at async /tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:245959
➤ YN0001: │ TypeError: fsevents@patch:fsevents@npm%3A2.1.2#builtin<compat/fsevents>::version=2.1.2&hash=87eb42: (0 , A.isDate) is not a function
    at /tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:419607
    at C.utimesImpl (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:419666)
    at C.utimesSync (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:419065)
    at C.utimesPromise (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:418931)
    at C.mkdirpPromise (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:383563)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async z.fetchers.patchPackage (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:217976)
    at async Q (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:244809)
    at async v (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:245268)
    at async /tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:245959
➤ YN0001: │ TypeError: resolve@patch:resolve@npm%3A1.20.0#builtin<compat/resolve>::version=1.20.0&hash=3388aa: (0 , A.isDate) is not a function
    at /tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:419607
    at C.utimesImpl (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:419666)
    at C.utimesSync (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:419065)
    at C.utimesPromise (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:418931)
    at C.mkdirpPromise (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:383563)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async z.fetchers.patchPackage (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:217976)
    at async Q (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:244809)
    at async v (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:245268)
    at async /tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:245959
➤ YN0001: │ TypeError: typescript@patch:typescript@npm%3A4.0.2#builtin<compat/typescript>::version=4.0.2&hash=5b02a2: (0 , A.isDate) is not a function
    at /tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:419607
    at C.utimesImpl (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:419666)
    at C.utimesSync (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:419065)
    at C.utimesPromise (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:418931)
    at C.mkdirpPromise (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:383563)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async z.fetchers.patchPackage (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:217976)
    at async Q (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:244809)
    at async v (/tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:245268)
    at async /tmp/renovate/repos/github/iiuni/projektzapisy/zapisy/.yarn/releases/yarn-berry.js:2:245959
➤ YN0013: │ 946 packages were already cached, 10 had to be fetched
➤ YN0000: └ Completed in 1.34s
➤ YN0000: Failed with errors in 1.76s

@renovate renovate Bot added the security label Aug 26, 2026
@renovate
renovate Bot force-pushed the renovate/npm-markdown-it-vulnerability branch 2 times, most recently from 9565d8e to 12d292f Compare September 29, 2026 20:51
@renovate
renovate Bot force-pushed the renovate/npm-markdown-it-vulnerability branch from 12d292f to be19e4b Compare October 5, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants