Skip to main content
Ben Nadel at InVision In Real Life (IRL) 2019 (Phoenix, AZ) with: RC Maples
Ben Nadel at InVision In Real Life (IRL) 2019 (Phoenix, AZ) with: RC Maples

Caution: CFDump Doesn't Encode CDATA Output In XML CFDump In Adobe ColdFusion 2025

By
Published in

While writing a Content Security Policy (CSP) compatible version of CFDump, I came across a number of bugs in Adobe ColdFusion's current implementation. Perhaps the most surprising one, however, is that CFDump doesn't encode the content in a CDATA block within an XML element. Which means that if an XML document is dumped-out, it's possible that embedded JavaScript will execute. Which can be dangerous — and is exactly the kind of thing my CSP HTTP header is there to prevent in the first place.

To see this in action, I've created two XML documents: one for the native CFDump implementation and one for my dump4csp.cfm implementation. Each carrying two means of JavaScript execution:

  • An explicit <script> block.
  • An onerror expression on an invalid <img> tag.

Note that each of these are in a <![CDATA[ content ]]> carve-out:

<cfscript>

	// ColdFusion language extensions (global functions).
	include "/core/cfmlx.cfm";

	// ------------------------------------------------------------------------------- //
	// ------------------------------------------------------------------------------- //

	// Native CFDump includes "1" and "2" alerts.
	doc = xmlParse("
		<node>
			<![CDATA[
				Script execution via tag:
				<script>alert( 1 );</script>

				Script execution via attribute:
				<img src='nope.jpg' onerror='alert( 2 )' />
			]]>
		</node>
	");

	writeDump(
		label = "Native CFDump",
		var = doc
	);

	// ------------------------------------------------------------------------------- //
	// ------------------------------------------------------------------------------- //

	// Dump4CSP includes "3" and "4" alerts.
	doc = xmlParse("
		<node>
			<![CDATA[
				Script execution via tag:
				<script>alert( 3 );</script>

				Script execution via attribute:
				<img src='nope.jpg' onerror='alert( 4 )' />
			]]>
		</node>
	");

	dump4csp(
		label = "Dump4CSP",
		var = doc
	);

</cfscript>

Now when we run this Adobe ColdFusion 2025 code, we can see the CFDump and the Dump4CSP output together. In the screenshot, I'm including the two alert() prompts triggered by the CFDump. In reality, the CFDump triggered four prompts since it actually renders the XML document twice — one simple format and one complex format — but the page only shows one format at a time.

Screenshots of XML dump in CFDump vs Dump4CSP showing JavaScript execution in native CFDump.

As you can see, we get two alert() prompts and broken output (where the script tag and img tag are evaluated rather than escaped). My Dump4CSP output renders encoded content as I would hope.

Obviously this isn't great. But the chance that you're ever rendering untrusted XML content via CFDump is next to nill. All XML is coming from a trusted source, like an API response; or when debugging XML content that your application is crafting for an API request.

Want to use code from this post? Check out the license.

Reader Comments

Post A Comment — I'd Love To Hear From You!

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
— Ben Nadel
Managed ColdFusion hosting services provided by:
xByte Cloud Logo