Skip to content

Commit 7ae2aaf

Browse files
committed
Merge branch 'drop-http-blocking-listener' of https://github.com/semenko/https-everywhere into semenko-drop-http-blocking-listener
Conflicts: chromium/background.js
2 parents 2a2dd7b + 2bf1c29 commit 7ae2aaf

File tree

1 file changed

+1
-48
lines changed

1 file changed

+1
-48
lines changed

chromium/background.js

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -326,47 +326,6 @@ function onCookieChanged(changeInfo) {
326326
}
327327
}
328328

329-
// This event is needed due to the potential race between cookie permissions
330-
// update and cookie transmission (because the cookie API is non-blocking).
331-
// Without this function, an aggressive attacker could race to steal a not-yet-secured
332-
// cookie if they controlled & could redirect the user to a non-SSL subdomain.
333-
// WARNING: This is a very hot function.
334-
function onBeforeSendHeaders(details) {
335-
// TODO: Verify this with wireshark
336-
for (var h in details.requestHeaders) {
337-
if (details.requestHeaders[h].name == "Cookie") {
338-
// Per RFC 6265, Chrome sends only ONE cookie header, period.
339-
var uri = new URI(details.url);
340-
var host = uri.hostname();
341-
342-
var newCookies = [];
343-
var cookies = details.requestHeaders[h].value.split(";");
344-
345-
for (var c in cookies) {
346-
// Create a fake "nsICookie2"-ish object to pass in to our rule API:
347-
var fake = {domain:host, name:cookies[c].split("=")[0]};
348-
// XXX I have no idea whether the knownHttp parameter should be true
349-
// or false here. We're supposedly inside a race condition or
350-
// something, right?
351-
var ruleset = all_rules.shouldSecureCookie(fake, false);
352-
if (ruleset) {
353-
activeRulesets.addRulesetToTab(details.tabId, ruleset);
354-
log(INFO, "Woah, we lost the race on updating a cookie: "+details.requestHeaders[h].value);
355-
} else {
356-
newCookies.push(cookies[c]);
357-
}
358-
}
359-
details.requestHeaders[h].value = newCookies.join(";");
360-
log(DBUG, "Got new cookie header: "+details.requestHeaders[h].value);
361-
362-
// We've seen the one cookie header, so let's get out of here!
363-
break;
364-
}
365-
}
366-
367-
return {requestHeaders:details.requestHeaders};
368-
}
369-
370329
function onBeforeRedirect(details) {
371330
// Catch HTTPs -> HTTP redirect loops, ignoring about:blank, HTTPS 302s, etc.
372331
if (details.redirectUrl.substring(0, 7) === "http://") {
@@ -382,11 +341,6 @@ function onBeforeRedirect(details) {
382341

383342
wr.onBeforeRequest.addListener(onBeforeRequest, {urls: ["https://*/*", "http://*/*"]}, ["blocking"]);
384343

385-
// This watches cookies sent via HTTP.
386-
// We do *not* watch HTTPS cookies -- they're already being sent over HTTPS -- yay!
387-
wr.onBeforeSendHeaders.addListener(onBeforeSendHeaders, {urls: ["http://*/*"]},
388-
["requestHeaders", "blocking"]);
389-
390344
// Try to catch redirect loops on URLs we've redirected to HTTPS.
391345
wr.onBeforeRedirect.addListener(onBeforeRedirect, {urls: ["https://*/*"]});
392346

@@ -412,8 +366,7 @@ chrome.tabs.onReplaced.addListener(function(addedTabId, removedTabId) {
412366
});
413367
});
414368

415-
// Listen for cookies set/updated and secure them if applicable. This function is async/nonblocking,
416-
// so we also use onBeforeSendHeaders to prevent a small window where cookies could be stolen.
369+
// Listen for cookies set/updated and secure them if applicable. This function is async/nonblocking.
417370
chrome.cookies.onChanged.addListener(onCookieChanged);
418371

419372
function disableSwitchPlannerFor(tabId) {

0 commit comments

Comments
 (0)