Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the "x-requested-with" http header be spoofed?

Tags:

http

security

My research shows that only the Host, Referer, and User-Agent headers can be spoofed. (source)

Is this a correct assumption to make? The security of a site I am building may require that "x-requested-with" cannot be faked. This is far from ideal but may be the only avenue I have.

like image 394
jdee Avatar asked Mar 08 '09 09:03

jdee


People also ask

What does Expected x-requested-with header mean?

1) include an X-Requested-With header that indicates that the request was made by XMLHttpRequest instead of being triggered by clicking a regular hyperlink or form submit button.

Can HTTP headers be sniffed?

The entire HTTP request (and response) is encrypted, including the URL. But yes, there is a way an attacker could grab the full URL: through the Referer header. If there is any external file (Javscript, CSS, etc.) which is not over HTTPS, the full URL could be sniffed in the Referer header.

Can HTTP headers be intercepted?

Once your site is accessed over HTTPS with no certificate errors, the browser knows your site is HTTPS capable and will honor the Strict-Transport-Security header. Browsers do this as attackers may intercept HTTP connections to the site and inject or remove the header.

Are request headers secure?

HTTP security headers are a fundamental part of website security. Upon implementation, they protect you against the types of attacks that your site is most likely to come across. These headers protect against XSS, code injection, clickjacking, etc.


3 Answers

The security of a site I am building may require that "x-requested-with" cannot be faked

Just about anything in HTTP can be spoofed. The level of 'spoofability' is hard to determine. It's fairly trivial to craft a request with any header value I desire.

If it's your only option, so be it, but I wouldn't want to use a site that relied on it for anything important.

like image 60
Greg Dean Avatar answered Oct 19 '22 05:10

Greg Dean


Every header can be spoofed. Any header that starts with x- is non-standard.

like image 31
some Avatar answered Oct 19 '22 04:10

some


Just came across this question, looking for something else, here is my answer:

A general security principle to bear in mind: any data can be altered.

Now from a practical standpoint here is what happens: The further down you operate on the stack (transport, network, link...) the more difficult it gets to alter the data because the tools needed are more likely to be unavailable to you in the first place and require system modifications (e.g. you can recompile a linux kernel to mess up with ethernet/IP stack if you're interested).

Talking about HTTP, that's application layer and it becomes dead easy to do whatever you want. You'll find tons of tools which will allow you to generate any custom HTTP requests from very basic network tools (nc, telnet...) to more advanced ones (cUrl,Fiddler...).

So NO the mere presence of the x-requested-with header can't be considered as proper security.

While it may be useful for low security level situations it will definitely not stop an attacker willing to go past it. Remember the first principle in security: no system in impenetrable, it just has to be secure enough to make breaking attempts unworthy.

like image 1
some dude Avatar answered Oct 19 '22 04:10

some dude