-
-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spoof Referer header of third party requests #2155
Changes from all commits
d79bec6
cced561
df0a7bb
2e66ed4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,6 +172,23 @@ function onBeforeSendHeaders(details) { | |
} else { | ||
return {}; | ||
} | ||
|
||
} else if (badger.isSpoofReferrerEnabled()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be an "else if", just an "if", since the "if this isn't a third-party request" block above always exits. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should move this entire referrer spoofing block down in We don't want to do this when Badger is disabled, and we already have a check for this later on in the callback ( We do want this to work in concert with DNT header injection though, so it makes sense for things that alter headers to live next to each other. |
||
if (badger.isPrivacyBadgerEnabled(tabDomain) && badger.isPrivacyBadgerEnabled(requestDomain)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't check |
||
// spoof referer header for third party requests | ||
const refererHeader = details.requestHeaders.find(header => header.name === "Referer"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we do a case-insensitive check here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style nit: |
||
if (refererHeader) { | ||
if (details.method === "GET") { | ||
// spoof referer value | ||
const requestUrl = new URL(details.url); | ||
refererHeader.value = requestUrl.origin; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we already have the origin in the |
||
} else { | ||
// remove referer header from non-GET request | ||
const refererHeaderIndex = details.requestHeaders.indexOf(refererHeader); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style nit: |
||
details.requestHeaders.splice(refererHeaderIndex, 1); | ||
} | ||
} | ||
} | ||
} | ||
|
||
var requestAction = checkAction(tab_id, requestDomain, frame_id); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be useful to have this text link out to an explanation of what a "referer" header is. Also, should we spell it the English way, or the canonical way? https://en.wikipedia.org/wiki/HTTP_referer