News for hackers. Stuff that matters.
Re:XSS Prevention Cheat Sheet by Ownatik on Wednesday January 26, 2011 @01:04PM (#2144174)
Good stuff but not really a cheat sheet...
Re:XSS Prevention Cheat Sheet by Xk on Wednesday January 26, 2011 @01:12PM (#2144232)
XSS prevention cheat sheet:

1) Never send untrusted data to the client.

How you do that isn't terribly important. It just matters that you do. Which is what that page is talking about: what you can do in order to never send untrusted data to the client.

Web developers would love it if there was a paragraph explanation that could explain how to prevent all XSS vulnerabilities in every site in detail, but there isn't.

Re:XSS Prevention Cheat Sheet by Xurinos on Wednesday January 26, 2011 @02:50PM (#2144780)
That's excellent! We can pair that with the other prevention cheat sheet:

1) Never trust what the client sends you.

AKA "How to prevent SQL injection and other such nasties"

Re:XSS Prevention Cheat Sheet by tptacek on Wednesday January 26, 2011 @03:10PM (#2144900)
These are the two least-useful pieces of advice in software security. Everyone has heard them, nobody is secure.

Great counter-indication of software security: "We have no SQL injection. No way. You'd get fired." What that tells me? You're not looking out for SQL injection; you think it can't happen.

Re:XSS Prevention Cheat Sheet by khafra on Wednesday January 26, 2011 @03:18PM (#2144940)
Someone here--it may have been you--highlighted this problem once as the difference between a diet that works and public policy on diet that works. If you actually follow the (security guidelines|diet), you'll be good; but naively telling people has very little effect.
Re:XSS Prevention Cheat Sheet by Xurinos on Wednesday January 26, 2011 @03:27PM (#2144987)
You can lead a horse to water, but you can't make it drink.
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.
Re:XSS Prevention Cheat Sheet by Semiapies on Wednesday January 26, 2011 @01:38PM (#2144382)
Absolutely right.

It might be nice to call this useful document something else, though. "XSS prevention summary" or whatever.

Re:XSS Prevention Cheat Sheet by veb on Wednesday January 26, 2011 @02:12PM (#2144577)
Isn't this better? http://ha.ckers.org/xss.html
Re:XSS Prevention Cheat Sheet by ax0n on Wednesday January 26, 2011 @02:36PM (#2144708)
No, that is an XSS exploitation (juxtapose: prevention) cheat sheet.
Re:XSS Prevention Cheat Sheet by veb on Wednesday January 26, 2011 @02:47PM (#2144764)
This is why I shouldn't come on the Internet in the morning, I simply cannot parse words correctly. Sorry.
Re:XSS Prevention Cheat Sheet by lurchpop on Wednesday January 26, 2011 @05:08PM (#2145408)
that's exactly what i was expecting. thanks!