GHSA-6v9c-7cg6-27q7
HIGHGHSA-6v9c-7cg6-27q7 is a high-severity (CVSS 7.5) vulnerability in marked. O3 Security confirms whether GHSA-6v9c-7cg6-27q7 is actually reachable in your code before you act, and blocks exploitation at runtime until you patch.
Marked Vulnerable to OOM Denial of Service via Infinite Recursion in marked Tokenizer
Real-World Exposure
markedReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects npm packages — download data is not available via public APIs for these ecosystems.
Description
Summary
A critical Denial of Service (DoS) vulnerability exists in [email protected]. By providing a specific 3-byte input sequence a tab, a vertical tab, and a newline (\x09\x0b\n)—an unauthenticated attacker can trigger an infinite recursion loop during parsing. This leads to unbounded memory allocation, causing the host Node.js application to crash via Memory Exhaustion (OOM).
Details
The vulnerability originates in how marked's block tokenizer handles unexpected whitespace characters.
- Tab Character (
\x09) Consumption: Thespace()tokenizer matches standard whitespace using the regex/^(?:[ \t]*(?:\n|$))+/. When parsing the malicious payload (\x09\x0b\n), this rule successfully consumes the initial tab character (\x09). - Vertical Tab (
\x0b) Bypass: The remaining input is now\x0b\n. The newline block rule explicitly looks for spaces or standard tabs ([ \t]) followed by a newline. Because the vertical tab is a legacy ASCII character not accounted for in this rule, it fails to match. - Fallback to Text Tokenizer: None of the standard block tokenizers (blockquote, code, heading, etc.) match
\x0b\n. As a result, the parser falls through to thetexttokenizer (/^[^\n]+/), which matches any character except a newline. - Infinite Recursion: Inside
blockTokens(), thetexttokenizer creates a text token and subsequently callsinlineTokens()on the exact same content. InsideinlineTokens(), the text rule again matches\x0b\nand recursively callsinlineTokens(). This creates an inescapable cycle:blockTokens() → text token → inlineTokens() → text rule matches → inlineTokens() → ...
With each recursive call allocating new token objects and concatenating strings, memory grows indefinitely until the Node.js heap limit is reached.
Vulnerable Code in lib/marked.esm.js (Lexer class, blockTokens()):
// The text tokenizer triggers infinite recursion
if(r=this.tokenizer.text(e)) {
e=e.substring(r.raw.length);
let s=t.at(-1);
s?.type==="text"?(s.raw+=(s.raw.endsWith("\n")?"":"\n")+r.raw, s.text+="\n"+r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src=s.text):t.push(r);
// ↑ This calls inlineTokens() internally via the text tokenizer, causing the OOM loop
continue;
}
PoC
This vulnerability can be reproduced using any standard Node.js environment with [email protected] installed.
- Create a file named
poc.jswith the following content:
const marked = require('marked');
// The vulnerable 3-byte pattern: tab + vertical tab + newline
const vulnerableInput = '\x09\x0b\n';
console.log('Attempting to parse malicious payload...');
try {
marked.parse(vulnerableInput);
} catch(e) {
console.log('Error:', e.message);
}
- Run the script:
node poc.js - Result: The process will hang briefly as memory spikes, ultimately crashing with:
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory.
Impact
This is a High-Severity Denial of Service (DoS) vulnerability via Memory Exhaustion.
Impacted Parties: Any application, API, chatbot, or documentation system using [email protected] (and potentially earlier versions) to parse untrusted user input is vulnerable.
Because the payload requires zero authentication and only 3 bytes of data, it requires virtually no resources from the attacker to remotely crash the service and achieve a total loss of availability for the targeted application.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | marked | ≥ 18.0.0&&< 18.0.2 | 18.0.2 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for marked. O3's reachability analysis confirms whether the vulnerable code path is actually invoked in your application, so you act on real exposure instead of every transitive match.
Fix
Update marked to 18.0.2 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-6v9c-7cg6-27q7 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 pinpoints whether GHSA-6v9c-7cg6-27q7 is reachable in your code and exactly where to fix it, then blocks exploitation in production at runtime until the patched version is deployed.
Tailored to GHSA-6v9c-7cg6-27q7. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is GHSA-6v9c-7cg6-27q7 in your dependencies?
O3 detects GHSA-6v9c-7cg6-27q7 across npm dependencies and uses function-level reachability to confirm whether the vulnerable code path is actually reachable — not just present. No false positives.