Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

HSTS Fingerprinting #527

Closed
wants to merge 1 commit into from
Closed

HSTS Fingerprinting #527

wants to merge 1 commit into from

Conversation

jumde
Copy link
Contributor

@jumde jumde commented Mar 12, 2018

Don't apply HSTS on 3rd party subresource loads, unless that subresource has been visited as a first party

Testing instructions:

  1. Open Brave. Disable HTTPS Everywhere in preferences.
  2. Open safebrowsing-proxy.brave.com (ping @jumde if the domain is not working)
  3. Verify that the ninja image is loaded with a 301 redirect even if the page is loaded multiple times.
  4. Clear browsing history (to avoid cached responses)
  5. Load https://avatars2.githubusercontent.com/u/1903815?s=40&v=4 in the URL bar
  6. Open safebrowsing-proxy.brave.com and confirm that the HTTPS upgrade happens with a 307 redirect instead of 301.

@diracdeltas
Copy link
Member

this is for brave/browser-laptop#12223 btw


void URLRequestHttpJob::NotifyHeadersComplete() {
- DCHECK(!response_info_);
+ std::string first_party_host = request_->site_for_cookies().host();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we care about this warning? https://cs.chromium.org/chromium/src/net/url_request/url_request.h?q=site_for_cookies&sq=package:chromium&l=270

site_for_cookies is used for firstPartyUrl in webRequest also; i don't exactly remember why we decided it wasn't an issue there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even in this case we are using site_for_cookies to figure out the first party url.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00 section 2.1, site for cookies is not the same as top-level site in a few cases:

  1. in a nested cross-origin iframe, the site-for-cookies is ''
  2. for shared workers belonging to documents with different origins, the site-for-cookies is ''

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess it doesn't matter in this case since we only use the first party host to check if it is the same as the request host (which would not be empty in the cases above): https://github.com/brave/muon/pull/527/files#diff-85ff0d997b1a2f089546f7b2823b0ad7R1869

+ }
+
ProcessPublicKeyPinsHeader();
ProcessExpectCTHeader();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should also move ProcessPublicKeyPinsHeader and ProcessExpectCTHeader into the if (first_party_host == request_host) {... block since they can be used for similar tracking

@diracdeltas
Copy link
Member

nice work! this looks like it'll work for new HSTS requests, but not HSTS state that the browser has already saved. can we delete the existing HSTS database when the user updates to this version of muon? (maybe can be done in browser-laptop)

@diracdeltas diracdeltas reopened this Mar 13, 2018
@diracdeltas
Copy link
Member

looks like TransportSecurityState::DeleteAllDynamicDataSince can clear all HSTS pins since the start of time

@bridiver
Copy link
Collaborator

this looks like something we could do in filtering in browser-laptop and add/remove the header as needed

@darkdh darkdh requested a review from bridiver March 14, 2018 04:36
@jumde
Copy link
Contributor Author

jumde commented Mar 15, 2018

Closing in favor of: brave/browser-laptop#13437

@jumde jumde closed this Mar 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants