Closed Bug 358548 Opened 18 years ago Closed 18 years ago

xmlhttprequest is not allowed to modify the Referer header

Categories

(Core :: XML, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: kmac34567, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0

If you change the referer using the setrequestheader, it does not correctly send the new updated referer, but rather the page the request was sent from. 

On the URL above, the referer that is sent should be http://google.com, but it is not.

Reproducible: Always

Steps to Reproduce:
1.Create a new xmlhttprequest 
2.Use setrequestheader to edit the referer


Actual Results:  
The normal referer is sent in the header.

Expected Results:  
The updated referer should've been sent.
Assignee: nobody → xml
Component: General → XML
Product: Firefox → Core
QA Contact: general → ashshbhatt
Version: unspecified → 1.8 Branch
You aren't allowed to spoof referrers because they're an important part of the security model.  Otoh, maybe it should be allowed since you're only spoofing it to the same site...
Summary: Referer header not sent correctly in xmlhttprequests → xmlhttprequest is not allowed to modify the Referer header
I think it makes the security model simpler if you're not allowed to spoof referers, and I don't see why you would want to be able to spoof them.
There was some discussion in bug 302263 about whether spoofing the Referer header for XMLHttpRequest should be allowed.
(In reply to comment #2)
> I think it makes the security model simpler if you're not allowed to spoof
> referers, and I don't see why you would want to be able to spoof them.
> 
For me, it is incredibly useful in building Greasemonkey scripts. 

That said, I don't see anyplace where the Firefox Team said they intentionally did this. And, considering it worked in 1.5, I assumed it was a bug. I still think it is.

Security wise, this can only be done on the same domain, so there is little to no security reason to do this.

Also, what is the purpose of the setrequestheader, if it does not have full access to the headers sent?


Component: XML → General
Product: Core → Firefox
Version: 1.8 Branch → 1.0 Branch
Oh, this is for a Greasemonkey script... hmm.  Can you do what you want using GM_xmlhttpRequest?  If not, maybe you could get a feature added to Greasemonkey allowing you to set the referrer header for GM_xmlhttpRequest.

Why did you move this from Core > XML to Firefox > General?
OS: Windows XP → All
Hardware: PC → All
Version: 1.0 Branch → Trunk
(In reply to comment #5)
> Oh, this is for a Greasemonkey script... hmm.  Can you do what you want using
> GM_xmlhttpRequest?  If not, maybe you could get a feature added to Greasemonkey
> allowing you to set the referrer header for GM_xmlhttpRequest.
Can one still do that? The Greasemonkey code appears to just use the same setrequestheader as normal web-pages do.


> Why did you move this from Core > XML to Firefox > General?

I wasn't aware that I had. Apologies, this is my first bug report, so if I did, I didn't intend to, and you can switch it to whatever you like.

OS: All → Windows XP
Hardware: All → PC
Version: Trunk → 1.0 Branch
Assignee: xml → nobody
OS: Windows XP → All
Product: Firefox → Core
QA Contact: ashshbhatt → general
Hardware: PC → All
Version: 1.0 Branch → Trunk
Component: General → XML
http://www.w3.org/TR/XMLHttpRequest/#dfn-setrequestheader
So Firefox does the right thing.

Could be a Greasemonkey bug though.
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → INVALID
XMLHttpRequests from chrome also have this restriction. Shouldn't it just apply to content XHRs, just like chrome XHRs have the ability to do cross-domain requests and content XHRs don't?
See bug 383178 for allowing it in chrome.
You need to log in before you can comment on or make changes to this bug.