Cross-Site Request Forgery

https://news.ycombinator.com/rss Hits: 8
Summary

Cross-Site Request Forgery (CSRF) is a confused deputy attack where the attacker causes the browser to send a request to a target using the ambient authority of the user’s cookies or network position. For example, attacker.example can serve the following HTML to a victim <form action="https://example.com/send-money" method="post"> <input type="hidden" name="to" value="filippo" /> <input type="hidden" name="amount" value="1000000" /> </form> and the browser will send a POST request to https://example.com/send-money using the victim’s cookies. Essentially all applications that use cookies for authentication need to protect against CSRF. Importantly, this is not about protecting against an attacker that can make arbitrary requests (as an attacker doesn’t know the user’s cookies), but about working with browsers to identify authenticated requests initiated from untrusted sources. Unlike Cross-Origin Resource Sharing (CORS), which is about sharing responses across origins, CSRF is about accepting state-changing requests, even if the attacker will not see the response. Defending against leaks is significantly more complex and nuanced, especially in the age of Spectre. Why do browsers allow these requests in the first place? Like anything in the Web platform, primarily for legacy reasons: that’s how it used to work and changing it breaks things. Importantly, disabling these third-party cookies breaks important Single-Sign On (SSO) flows. All CSRF solutions need to support a bypass mechanism for those rare exceptions. (There are also complex intersections with cross-site tracking and privacy concerns, which are beyond the scope of this article.) Same site vs same site vs same origin To protect against CSRF, it’s important to first define what is a cross-site or cross-origin request, and which should be allowed. https://app.example.com, https://marketing.example.com, and even http://app.example.com (depending on the definition) are all same-site but not same-origin. It’s tem...

First seen: 2025-08-13 18:05

Last seen: 2025-08-14 01:09