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

Strip cookies from requests fetch favicons #14286

Merged
merged 1 commit into from
May 31, 2018
Merged

Conversation

Slava
Copy link
Contributor

@Slava Slava commented May 30, 2018

Fixes #14250
Auditors: @diracdeltas

This is a quick and dirty fix for #14250. It involves some sketchy action on a distance and we can discuss what can be improved about it.

Test Plan:
Manually navigate to https://www.grc.com/cookies/forensics.htm and observe no problems in the report
Navigate to a website with a favicon (such as github.com) and observe the favicon rendering

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Request a security/privacy review as needed. (Ask a Brave employee to help if you cannot access this document.)

Test Plan:

Reviewer Checklist:

  • Request a security/privacy review as needed if one was not already requested.

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

wrapFaviconUrl: (url) => `${url}${suffix}`,
unwrapFaviconUrl: (url) => url.substring(0, url.length - suffix.length),
isWrappedFaviconUrl: (url) => url.endsWith(suffix)
}
Copy link
Member

Choose a reason for hiding this comment

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

minor: please move to js/lib

@Slava
Copy link
Contributor Author

Slava commented May 31, 2018

@diracdeltas added tests

var host = window.location + ''
var parts = host.split('/')
parts.splice(-1, 1)
host = parts.join('/')
Copy link
Member

Choose a reason for hiding this comment

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

you could just do var host = window.location.origin

require('../../braveUnit')

describe('faviconUtil', function () {
it('wraps, identifies and unwarps URLs', function () {
Copy link
Member

Choose a reason for hiding this comment

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

minor: s/unwarp/unwrap

host = parts.join('/')

function loadIco() {
var faviconLocation = host.replace('127.0.0.1', 'localhost') + '/cookie-favicon.ico'
Copy link
Member

Choose a reason for hiding this comment

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

do you need to git add cookie-favicon.ico?

Copy link
Member

Choose a reason for hiding this comment

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

@diracdeltas
Copy link
Member

@@ -1053,4 +1053,28 @@ describe('Bravery Panel', function () {
})
})
})

// see #14250
describe('Favicon requests cannot set cookies', function () {
Copy link
Member

Choose a reason for hiding this comment

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

nice test!

Fixes brave#14250
Auditors: @diracdeltas

Test Plan:
Manually navigate to  https://www.grc.com/cookies/forensics.htm and observe no problems in the report
Navigate to a website with a favicon (such as github.com) and observe the favicon rendering

Unit tests:
run the faviconUtil unit tests

Webdriver test:
Runs a test page that sets a 3rd party cookie and checks if the favicon request carries over the cookies
@Slava
Copy link
Contributor Author

Slava commented May 31, 2018

Weird, yarn run lint finishes without problems for me locally. Let's see if the CI passes on the new revision.

Copy link
Member

@diracdeltas diracdeltas left a comment

Choose a reason for hiding this comment

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

confirmed that the test page fails without this change and succeeds with it.

one issue is that Favicon requests cannot set cookies test passes even without this change. we looked into it for a while and couldn't figure out why cookies were not being sent in the webdriver favicon request even when they are set.

@diracdeltas diracdeltas added this to the 0.24.x (Nightly Channel) milestone May 31, 2018
@diracdeltas diracdeltas merged commit c08c815 into brave:master May 31, 2018
@diracdeltas
Copy link
Member

master / 0.24.x: c08c815

bsclifton pushed a commit that referenced this pull request Jul 31, 2018
Strip cookies from requests fetch favicons
@bsclifton
Copy link
Member

Uplifted to 0.23.x with e104f5a

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.

cookie testing site shows leaks
3 participants