News for hackers. Stuff that matters.
Re:XSS Prevention Cheat Sheet by pornel on Wednesday January 26, 2011 @05:04PM (#2145393)
Actually, that's not entirely correct. It should be:

1) escape data to prevent it from being interpreted as code

Because this security problem is just subset of markup correctness problem.

If you escape data perfectly, then both trusted and untrusted data won't be misinterpreted, e.g. I can echo any evil input if my character encoding is enforced and HTML special chars are escaped as entities. I can send any untrusted nastiness to database via prepared SQL statement.

Re:XSS Prevention Cheat Sheet by Xurinos on Wednesday January 26, 2011 @05:10PM (#2145428)
> escape data to prevent it from being interpreted as code

What about too much data? Overflow is a concern, too. Escaping is just one solution, so I shot for the more general rule.

Re:XSS Prevention Cheat Sheet by pornel on Wednesday January 26, 2011 @05:42PM (#2145583)
> What about too much data? Overflow is a concern

Buffers are not supposed to overflow with trusted data either, so again, security is subset of correctness. "Not trusting" data only prevents exploit from reaching vulnerable code, it doesn't fix the vulnerability.

Don't write web applications C? ;)

Re:XSS Prevention Cheat Sheet by Swannie on Thursday January 27, 2011 @06:07AM (#2147390)
"e.g. I can echo any evil input if my character encoding is enforced and HTML special chars are escaped as entities."

FAIL :-P

AFAIK You need to JS escape anything that goes into a JS context too.

Re:XSS Prevention Cheat Sheet by pornel on Friday January 28, 2011 @06:30PM (#2153956)
You're right - escaping is very dependent on context, and sometimes you need to escape data multiple times in nested contexts.

In inline script you need to get JS string escaping right and avoid </ sequence that ends HTML CDATA.

Re:XSS Prevention Cheat Sheet by Xurinos on Thursday January 27, 2011 @12:10PM (#2148567)
And if you send that data from JS to the server, you cannot rely on the theory that JS massaged that data first.