<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Marked — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/marked/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata — refreshed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Wed, 03 Jan 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/marked/feed.xml" rel="self" type="application/rss+xml"/><item><title>Denial of Service Vulnerability in marked via Infinite Recursion</title><link>https://feed.craftedsignal.io/briefs/2024-01-03-marked-dos/</link><pubDate>Wed, 03 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-03-marked-dos/</guid><description>A denial of service vulnerability exists in marked version 18.0.0 due to infinite recursion when processing a specific 3-byte sequence (tab, vertical tab, and newline), leading to unbounded memory allocation and application crash.</description><content:encoded><![CDATA[<p>A critical Denial of Service (DoS) vulnerability has been identified in <code>marked@18.0.0</code>. This vulnerability arises from the processing of a specific 3-byte input sequence: a tab character, a vertical tab character, and a newline character (<code>\x09\x0b\n</code>). An unauthenticated attacker can exploit this by sending this sequence to a Node.js application utilizing the vulnerable version of the <code>marked</code> library. This input triggers an infinite recursion loop within the <code>marked</code> tokenizer during parsing, leading to unbounded memory allocation and ultimately causing the host Node.js application to crash due to Memory Exhaustion (OOM). This vulnerability allows for a total loss of availability for any application using the vulnerable library to process potentially untrusted input.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>The attacker sends a crafted input string containing the sequence <code>\x09\x0b\n</code> to a Node.js application using <code>marked@18.0.0</code>.</li>
<li>The <code>space()</code> tokenizer in <code>marked</code> consumes the initial tab character (<code>\x09</code>) using the regex <code>/^(?:[ \t]*(?:\n|$))+/</code>.</li>
<li>The newline block rule fails to match the remaining <code>\x0b\n</code> sequence because the vertical tab is not accounted for in the rule <code>[ \t]</code>.</li>
<li>The parser falls through to the <code>text</code> tokenizer (<code>/^[^\n]+/</code>), which matches the <code>\x0b\n</code> sequence.</li>
<li>Inside the <code>blockTokens()</code> function, the <code>text</code> tokenizer creates a text token.</li>
<li>The <code>blockTokens()</code> function then calls <code>inlineTokens()</code> on the same input (<code>\x0b\n</code>).</li>
<li>The <code>inlineTokens()</code> function&rsquo;s text rule matches <code>\x0b\n</code> and recursively calls <code>inlineTokens()</code> again, leading to an infinite loop.</li>
<li>Each recursive call allocates new token objects and concatenates strings, causing memory usage to grow until the Node.js heap limit is reached, resulting in a crash.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>This vulnerability results in a High-Severity Denial of Service (DoS) via Memory Exhaustion. Any application, API, chatbot, or documentation system using <code>marked@18.0.0</code> to parse untrusted user input is vulnerable. The attack requires minimal resources from the attacker, only the ability to send a 3-byte payload, to cause a total loss of availability. The vulnerability affects <code>npm/marked</code> versions greater than or equal to 18.0.0 and less than or equal to 18.0.1.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade to a patched version of the <code>marked</code> library that addresses the infinite recursion vulnerability.</li>
<li>Monitor Node.js application logs for error messages indicating memory exhaustion or crashes, which might indicate exploitation attempts.</li>
<li>Implement input validation to sanitize or reject input containing the malicious <code>\x09\x0b\n</code> sequence.</li>
<li>Deploy the Sigma rule for <code>marked</code> process crashes due to memory exhaustion to identify exploitation attempts.</li>
</ul>
]]></content:encoded><category domain="severity">medium</category><category domain="type">advisory</category><category>denial-of-service</category><category>javascript</category><category>marked</category><category>vulnerability</category></item></channel></rss>