Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Firefox not always send the HTTP Origin header for POST requests?

Tags:

http

firefox

I'm exploring the idea of HTTP Origin checks as CSRF protection for Drupal at https://www.drupal.org/node/1803712

Now I was testing how the Origin header arrives with a POST request, but Firefox does not send the Origin header on the user login form submission. Chromium and Chrome work fine, they send the Origin header.

Firefox version is 36.0.1. I also tested with a clean Firefox installation because I thought maybe some of my browser plugins suppress the Origin header, but no luck - no Origin header there either.

Is there a documentation page that describes when Firefox sends the Origin header and when not?

like image 599
klausi Avatar asked Mar 13 '15 14:03

klausi


People also ask

Why is origin not sending my header?

Also, for completeness here and to be clear: For navigations, browsers send no Origin header. That is, if a user navigates directly to a resource — by pasting a URL into a browser address bar, or by following a link from another web document — then browsers send no Origin header. Save this answer.

Is the Origin header always sent?

Cross-origin requests have an origin header that identifies the domain initiating the request and is always sent to the server.

How do I allow Origin header?

Simply add a header to your HttpServletResponse by calling addHeader : response. addHeader("Access-Control-Allow-Origin", "*");

Does the browser add the Origin header?

The Origin HTTP Header is a response HTTP header that indicates the security contexts that initiates an HTTP request without indicating the path information. The Origin header is added by the browser and can not be controlled by the user.


2 Answers

Is isn't implemented yet. There's a discussion here: https://bugzilla.mozilla.org/show_bug.cgi?id=446344

like image 94
Marco Castelluccio Avatar answered Oct 25 '22 18:10

Marco Castelluccio


The default on Firefox is not to send HTTP_ORIGIN.

The reason is a bug that causes hangs on some mobile Firefox versions if the network.http.sendOriginHeader configuration variable (accessible via about:config) is enabled. (For details see https://developer.mozilla.org/en-US/Firefox/Experimental_features#Security and the link provided by Marco's comment https://bugzilla.mozilla.org/show_bug.cgi?id=446344.)

There is a proposal to enable FF sending HTTP_ORIGIN by default, but the TODO list is long (see https://bugzilla.mozilla.org/show_bug.cgi?id=1424076). So it will probably take years until FF will generally send HTTP_ORIGIN even without Javascript code enabling CSRF.

Some FOSS OSes preconfigure their FF ports to send HTTP_ORIGIN by default. BTW, MS Edge also does not send HTTP_ORIGIN without explicitly enabling CSRF using Javascript.

For this reason I have implemented a security setting of my site which enables the users to disallow POST transactions from browsers that do not provide HTTP_ORIGIN.

like image 22
dumbo Avatar answered Oct 25 '22 18:10

dumbo