When Previewing Becomes Dangerous
Note: The following article was published on 29/11/2015 on https://FogMarks.com
Previewing is cool. A lot of web sites and services offer a ‘preview before posting’ or ‘preview before buying’ option.
But sometimes previewing becomes a dirty business. Like in this case-study your’e about to hear.
Before sending the invoice, your are allowed to preview the message you are about to send to the client. Clicking on the preview button opens a pop up window which shows an example of the invoice.
When I clicked on ‘preview’ I noticed that the ‘Enter’ char I inserted was translated to a ‘<br />’ text on the GET message body parameter (in the URL). I changing the input to </script><svg onload=alert(document.domain)></svg> didn’t work. That was the stage where I’ve started to think.
I have decided to analyze each GET parameter in the request, and noticed that one of them was referring to a template id.
The template id was wrapping the message with a nice css and some images. It changes the background color, the foreground color and the font of the input. Then I figured: “Hmm, the template determines the input’s font. Maybe it also reads the input and has an XSS filter on the it?.”
I wondered: What if the template id will be of a non-existent template? I changed the id to some random number, entered the XSS payload again and bam! It worked.
The XSS filter was set per-template, which means that it worked only when an existing template id was supplied. When I supplied a non-existent template id — there was no XSS filter, no nice css or images, but still the payload was generated, which resulted with a nice reflected XSS.
Allowing only some of the parameters of a request to affect the output might be risky. Always be aware of the impact and the importance of any parameter you use, even the smallest one.
Blinksale patched this issue and personally thanked me via email.