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

Commit

Permalink
Block loading .onion sites in non-Tor tabs.
Browse files Browse the repository at this point in the history
fix #14431

Auditors: @diracdeltas @bsclifton

Test Plan:
I:	1. Open a tab _without_ Tor (private or nonprivate).
	2. Enter https://nyttips4bmquxfzw.onion/.
	3. Confirm that Brave blocks loading the URL.

II:	1. Open a private tab with Tor.
	2. Enter https://nyttips4bmquxfzw.onion/.
	3. Confirm that the NYT SecureDrop page loads.
	4. Bookmark it.
	5. Open a tab _without_ Tor (private or nonprivate).
	6. Try to load the bookmark.
	7. Confirm that Brave blocks loading the bookmark.
  • Loading branch information
riastradh-brave committed Jul 11, 2018
1 parent e78fc93 commit 855c5a4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/extensions/brave/locales/en-US/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ submit=Submit
tabsSuggestionTitle=Tabs
topSiteSuggestionTitle=Top Site
urlBlockedInTor=For your privacy, Brave blocks this URL from loading in a private tab when Tor is enabled.
urlBlockedOutsideTor=For your privacy, Brave blocks this URL from loading in a tab without Tor.
urlWarningOk=Ok
torConnectionError=Unable to connect to the Tor network
torConnectionErrorInfo=Brave could not make a connection to the Tor network. Disable Tor to continue private browsing without Tor protection.
Expand Down
21 changes: 21 additions & 0 deletions app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ function registerForBeforeRequest (session, partition) {
onBlockedInTor(details, muonCb)
return
}
} else {
const host = urlParse(details.url).host
// US-ASCII only in `.onion', so no need for locale-dependent
// case-insensitive comparisons.
if (host.toLowerCase().endsWith('.onion')) {
onBlockedOutsideTor(details, muonCb)
return
}
}

if (process.env.NODE_ENV === 'development') {
Expand Down Expand Up @@ -406,6 +414,19 @@ function onBlockedInTor (details, muonCb) {
}
}

function onBlockedOutsideTor (details, muonCb) {
const cb = () => muonCb({cancel: true})
if (details.tabId && details.resourceType === 'mainFrame') {
tabMessageBox.show(details.tabId, {
message: `${locale.translation('urlBlockedOutsideTor')}`,
title: 'Brave',
buttons: [locale.translation('urlWarningOk')]
}, cb)
} else {
cb()
}
}

/**
* Register for notifications for webRequest.onHeadersReceived for a particular
* session.
Expand Down
1 change: 1 addition & 0 deletions app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ var rendererIdentifiers = function () {
'noDownloads',
'torrentDesc',
'urlBlockedInTor',
'urlBlockedOutsideTor',
'urlWarningOk',
'multiSelectionBookmarks',
// Caption buttons in titlebar (min/max/close - Windows only)
Expand Down

0 comments on commit 855c5a4

Please sign in to comment.