4 ms·
> By default jQuery sends the X-Requested-With header. It was thought that the mere presence of this header could be used as a way to defeat Cross-Site Request
by stephenr 13y ago
> By default jQuery sends the X-Requested-With header. It was thought that the mere presence of this header could be used as a way to defeat Cross-Site Request Forgery.
By who? Who thought the mere presence of an arbitrary header made the request "safe"?
Seriously, who the fuck thought this was a good idea? I have so far seen one single use for X-Requested-With - returning a page as "content only" - i.e. omitting the header, nav, footers etc for XHR calls.
- simonw 13y agoLoads of people thought it was a good idea. Traditional CSRF attacks work by pointing an HTML form on an evil third party site at an endpoint on the trusted site. HTML forms can't include custom HTTP headers, and you can't make Ajax requests (which can have custom headers) to different domains due to the same-origin policy - so the presence of an X-Requested-With header should be enough to "prove" that the request came from the same domain as you and not from a site run by an attacker. Unfortunately certain versions of the Flash and JavaScript plugins allow requests to be made to other domains with custom headers, which left CSRF holes open.
- michaelmior 13y agoWhat do you mean by "JavaScript plugin"?
- richbradshaw 13y agoThink it's a typo for Java.
- michaelmior 13y agoAh, that makes sense! Been such a long time since I've run a Java applet that I don't think about them anymore.
- e28eta 13y agoMy guess was browser plugins (implemented in Javascript).