Status/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): David Epler / David Epler (David Epler)
Created: 12/28/2012
Components: Security
Versions: 10.0
Failure Type: Enhancement Request
Found In Build/Fixed In Build: Final /
Priority/Frequency: Trivial / Unknown
Locale/System: English / Platforms All
Vote Count: 4
While ColdFusion 10 added the various ESAPI encodeFor* functions, it is dependent upon the developer to properly wrap location where used with the appropriate function (e.g. <cfoutput>#EncodeForHTML(url.name)#</cfouput>). Adding an attribute encodeFor negates the need for wrapping individual variables and would process the entire block contained within <cfoutput> for anything within #'s with the appropriate ESAPI EncodeFor* function specified.
<cfouput encodeFor="HTML">
#url.name#<br>
#url.title#
</cfoutput>
or
<cfscript>
writeOutput(url.name, "HTML");
</cfscript>
All the ESAPI encoders should be available as attributes: HTML, HTMLAttribute, XML, XMLAttribute, CSS, Javascript, URL
Another example:
<cfouput encodeFor="HTML">
#url.name#
<a href="whatever.cfm?id=#EncodeForURL(url.id)#">Link</a>
</cfoutput>
In the case above the EncodeForURL should take precedence over the EncodeForHTML that would normally occur for just what it is wrapped around. So url.id would be EncodeForURL, while url.name and all other #'s would still be EncodeForHTML.
Default could be set to "none" for backwards compatibility (or "html" for secure profile). Possibly have a server and application level setting to define the default encode. This would make it much easier to deal with blocks of code and provide an easy way to protect against XSS, especially in legacy code bases.
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3434473
External Customer Info:
External Company:
External Customer Name: David Epler
External Customer Email:
Attachments:
Comments: