CVE-2026-47080: CDATA Section Breakout via Unsanitised ]]> in xml_builder
XML Injection vulnerability in joshnuss xmlbuilder (XmlBuilder module) allows Content Spoofing, XML Injection.
This vulnerability is associated with program files lib/xmlbuilder.ex and program routines XmlBuilder.generate/1, XmlBuilder.generate/2, XmlBuilder.escape/1.
The escape/1 clause for {:cdata, data} in lib/xmlbuilder.ex concatenates data verbatim between the CDATA opener <![CDATA[ and closer ]]> without rewriting or splitting on the embedded ]]> sequence. Because CDATA sections have no internal escape mechanism, the only safe way to embed arbitrary bytes is to split on ]]> and emit adjacent CDATA sections. An attacker who can supply input containing ]]> closes the CDATA section early; any bytes that follow are parsed as ordinary XML markup by downstream consumers, allowing injection of arbitrary elements, text, or entity references into the output document.
This issue affects xmlbuilder: from 0.0.7 before 2.4.1.
Affected Software
Event History
Frequently Asked Questions
Which deployments are exposed?
Deployments using xml_builder versions from 0.0.7 through versions before 2.4.1 are affected when they place attacker-controlled data in a {:cdata, data} value processed by XmlBuilder.escape/1.
What must an attacker provide to exploit this issue?
The attacker needs control of content emitted as CDATA and must include the sequence ]]> followed by XML content. The sequence closes the generated CDATA section, causing following bytes to be interpreted as ordinary XML markup by downstream consumers.
Are all uses of xml_builder affected by default?
The vulnerable behavior is specific to the {:cdata, data} escape/1 clause. Uses that do not put untrusted input into CDATA are not described as exploitable by this issue.
What can be done if upgrading is not immediately possible?
Do not pass untrusted data as CDATA without handling embedded ]]> sequences. Split such data on ]]> and emit adjacent CDATA sections so the sequence cannot terminate a CDATA section early.