Описание
Marked Vulnerable to OOM Denial of Service via Infinite Recursion in marked Tokenizer
Summary
A critical Denial of Service (DoS) vulnerability exists in marked@18.0.0. 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()):
PoC
This vulnerability can be reproduced using any standard Node.js environment with marked@18.0.0 installed.
- Create a file named
poc.jswith the following content:
- 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 marked@18.0.0 (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.
Пакеты
marked
>= 18.0.0, <= 18.0.1
18.0.2
EPSS
8.7 High
CVSS4
7.5 High
CVSS3
CVE ID
Дефекты
Связанные уязвимости
Marked is a markdown parser and compiler. From 18.0.0 to 18.0.1, a critical Denial of Service (DoS) vulnerability exists in marked. 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). This vulnerability is fixed in 18.0.2.
Marked is a markdown parser and compiler. From 18.0.0 to 18.0.1, a critical Denial of Service (DoS) vulnerability exists in marked. 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). This vulnerability is fixed in 18.0.2.
Marked is a markdown parser and compiler. From 18.0.0 to 18.0.1, a critical Denial of Service (DoS) vulnerability exists in marked. 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). This vulnerability is fixed in 18.0.2.
Marked is a markdown parser and compiler. From 18.0.0 to 18.0.1, a cri ...
EPSS
8.7 High
CVSS4
7.5 High
CVSS3