<?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>Dom — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/tags/dom/</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/tags/dom/feed.xml" rel="self" type="application/rss+xml"/><item><title>xmldom XML Injection Vulnerability</title><link>https://feed.craftedsignal.io/briefs/2024-01-xmldom-xml-injection/</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-xmldom-xml-injection/</guid><description>The xmldom package is vulnerable to XML injection. The package serializes DocumentType node fields (internalSubset, publicId, systemId) verbatim without any escaping or validation. When these fields are set programmatically to attacker-controlled strings, XMLSerializer.serializeToString can produce output where the DOCTYPE declaration is terminated early and arbitrary markup appears outside it. To address this applications that pass untrusted data to createDocumentType() or write untrusted values directly to a DocumentType node's publicId, systemId, or internalSubset properties should audit all serializeToString() call sites and add the option.</description><content:encoded><![CDATA[<p>The <code>@xmldom/xmldom</code> and <code>xmldom</code> packages are vulnerable to XML injection due to the lack of validation when serializing <code>DocumentType</code> node fields. Specifically, the <code>internalSubset</code>, <code>publicId</code>, and <code>systemId</code> fields are serialized verbatim without any escaping or validation. This vulnerability affects <code>@xmldom/xmldom</code> versions prior to 0.8.13 and versions 0.9.0 to 0.9.9, as well as <code>xmldom</code> versions up to 0.6.0. The vulnerability is triggered when these fields are programmatically set to attacker-controlled strings, leading to potential arbitrary markup injection outside the DOCTYPE declaration during serialization using <code>XMLSerializer.serializeToString</code>. This can lead to downstream XML parsers being susceptible to XXE attacks. Defenders should audit serializeToString() call sites and add <code>{ requireWellFormed: true }</code> to mitigate this vulnerability.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>The attacker identifies an application using a vulnerable version of <code>@xmldom/xmldom</code> or <code>xmldom</code>.</li>
<li>The attacker finds a code path where they can control the <code>publicId</code>, <code>systemId</code>, or <code>internalSubset</code> properties of a <code>DocumentType</code> node.</li>
<li>The attacker crafts a malicious string containing XML injection payloads (e.g., closing DOCTYPE tags or injecting SYSTEM entities).</li>
<li>The attacker uses programmatic calls to <code>createDocumentType</code> or direct property writes to set the malicious string as the value of the <code>publicId</code>, <code>systemId</code>, or <code>internalSubset</code> field.</li>
<li>The application calls <code>XMLSerializer.serializeToString</code> on the document, without the <code>{ requireWellFormed: true }</code> option.</li>
<li>The vulnerable serializer emits a DOCTYPE declaration where the injected malicious string is included verbatim, causing the DOCTYPE declaration to be terminated early or to include injected entities.</li>
<li>The serialized XML is passed to a downstream XML parser that performs entity expansion.</li>
<li>The downstream XML parser expands the injected entities, leading to potential XXE attacks, information disclosure, or other malicious actions.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of this vulnerability can lead to the injection of arbitrary XML markup, potentially enabling XXE attacks against downstream XML parsers. The impact includes potential information disclosure, arbitrary code execution, or denial-of-service if the downstream parser expands external entities. This vulnerability impacts applications using vulnerable versions of <code>@xmldom/xmldom</code> and <code>xmldom</code> that construct <code>DocumentType</code> nodes from user-controlled data and serialize the document without proper validation.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade to <code>@xmldom/xmldom</code> version 0.8.13 or later, or version 0.9.10 or later, to receive the fix.</li>
<li>Upgrade to a version of <code>xmldom</code> greater than 0.6.0.</li>
<li>Audit all calls to <code>XMLSerializer.serializeToString()</code> and add the option <code>{ requireWellFormed: true }</code> to enforce validation of <code>DocumentType</code> node fields, as described in the advisory.</li>
<li>Applications that pass untrusted data to <code>createDocumentType()</code> or write untrusted values directly to a <code>DocumentType</code> node&rsquo;s <code>publicId</code>, <code>systemId</code>, or <code>internalSubset</code> properties should audit all <code>serializeToString()</code> call sites and add the option.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>xml-injection</category><category>xxe</category><category>dom</category><category>xmldom</category></item></channel></rss>