Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not necessarily. Typical CSRF implementations prevent the server from accepting inputs coming from an "unauthorized" page. This might or might not prevent XSS from being triggered on the client side.

XSS can propagate to other users via database rather than HTTP requests.

In general, you should prevent attacks in one-by-one manner. Hoping that one security mechanism will accidentally fix other issues will result in design that is insecure, convoluted and hard to reason about. Remember: you have to prevent all attacks. Attackers only need to find one vulnerability to attack. Therefore, any kind of complexity in design works to their advantage.



Exactly, defense in depth is the name of the game.

An example of a defense in depth strategy:

Layer 1: Customer runs a WAF (web app firewall) to do some CSRF and XSS mitigation

Layer 2: App contains its own intrusion detection system that preprocesses all requests for "typical" SQL injection, CSRF and XSS attacks and prevents the rest of the code from executing if this is the case. I'm using PHP-IDS for this.

Layer 3: every request to the server must submit an anti-CSRF token and is immediately refused if it does not do so.

Layer 4: Business logic contains its own positive input validation (all input must be in the expected format), and prevents the rest of the code from executing if the input is not valid. This is meant to prevent XSS and SQL injection when data enters the system.

Layer 5: all DB requests use parameters instead of concatenating variables into queries to mitigate the risk of SQL injection.

Layer 6: All output is encoded to prevent XSS attacks when data leaves the system.

In such a solution you can have a security issue in one of the layers and still have a system that is secure.


Exactly. Don't defend from XSS by implementing CSRF defences. Defend from XSS by making sure you properly encode every piece of data that enters your web page. Then add CSRF on top, to prevent third party sites from initiating "clicks" on your page. Then implement Content-Security-Policy to help defend against programmer mistakes which leave CSRF/XSS holes open.


I agree that XSS can propagate to other users via database...I'm pretty sure the expresslane example is a real vulnerability for that reason. But note that the grandparent post was not describing an attack via the database.

I am not hoping that CSRF prevention will make everything OK on the Apple website (which I have no affiliation with, by the way). Nor am I saying XSS prevention is not worthwhile. I'm merely pointing out that this blog post is not demonstrating 11 vulnerabilities in Apple's web site. There might actually be 11 vulnerabilities, but the blog post doesn't give enough information for us to know.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: