Debug Message XSS Vulnerabilities - Michael Sutton's Blog -
Debug Message XSS Vulnerabilities

I was excited this afternoon when I thought that I'd stumbled upon a universal XSS vulnerability in verbose ColdFusion error messages. While testing a site, I had noted that a verbose debug error message (see below) echoed back many of the request headers, including the Referrer and User-Agent (aka Browser) headers.


Error Occurred While Processing Request

Error Diagnostic Information

An error occurred while evaluating the expression:

#Form.XXX#

Error near line 5, column 20.


Error resolving parameter FORM.XXX

The specified form field cannot be found. This problem is very likely due to the fact that you have misspelled the form field name.

The error occurred while processing an element with a general identifier of (#Form.XXX#), occupying document position (5:19) to (5:33).

Date/Time: 03/22/07 22:36:03
Browser: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Remote Address: 69.255.12.149
HTTP Referer: http://www.XXX.org:80/admin/
Query String: action=login&sub=validate


Naturally, curiosity got the best of me and I attempted to inject JavaScript into the headers only to find that yes indeed, the injected JavaScript was echoed back without being sanitized, which makes for a nice XSS vulnerability on all ColdFusion sites which don't suppress such error messages. Alas, my hopes were dashed when I realized that I'd been beaten to the punch. Despite the setback, I was still curious to see how many sites would be affected by the vulnerability and was blown away when my friend Google suggested that the number may be in the six figure range.

Knowing that, my curiosity was peaked again, so I started poking around to see if I could find other third party or custom web apps which exposed XSS vulnerabilities by echoing back raw request headers. A bit of creative Googling suggested that many have made the same mistake:

The moral of this story is that we must think broadly when defining user input. Data does not need to come from a web form to be considered user supplied input. Headers, cookies, hidden form fields, etc. all come from the client and can therefore be manipulated by an attacker. When building web apps, we need to define user input as ANYTHING that is sent from the client to the server.

- michael


Posted 03-23-2007 12:35 AM by erik.peterson

Comments

Ory wrote re: Debug Message XSS Vulnerabilities
on 03-25-2007 8:47 AM

The amazing thing about ColdFusion error messages XSS, is that it exists in almost every single new release of the product....they just can't get it right.

Steve Christey wrote re: Debug Message XSS Vulnerabilities
on 03-29-2007 7:43 PM

Error message XSS was a PHP interpreter issue until about a year ago, when display_errors was on.    Didn't always need to involve headers.  Apparently they fixed it, but vulnerable PHP's are probably still in many installations.  Undoubtedly this "feature" is at least part of the increase in XSS vulns recorded by CVE.  How much is unclear, but maybe 5-10% of XSS reports in PHP apps?

pagvac wrote re: Debug Message XSS Vulnerabilities
on 03-30-2007 4:37 PM

I remember also getting excited when I noticed this for the first time, and then noticed that whiteacid already mentioned it as well. :-(

I even downloaded and installed the trial version of Coldfusion 7 MX, and it *did* also work!

Of course, you need to forge the user-agent header which cannot be natively done by the browser, unless you do some Flash trickery for instance to add custom headers.

Any other ways to forge the user-agent header "on the fly"? (no windows registry hacks please!)