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
onerrorexpression 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.
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.
Reader Comments
I filed a bug in the Adobe Tracker -
CF-4235804- but since I defined it as a "security" bug, it's automatically made private and I can't link to it.Post A Comment — ❤️ I'd Love To Hear From You! ❤️
Post a Comment →