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

Commit

Permalink
defense in depth against Flash/ledger running on tor tabs (#14482)
Browse files Browse the repository at this point in the history
use the new torEnabled content script settings to block content scripts that
shouldn't be runnning in Tor tabs

fix #14480

Test Plan:
1. open tor tab
2. go to http://www.ultrasounds.com/
3. you should not see a notification to run flash
  • Loading branch information
diracdeltas committed Jun 22, 2018
1 parent de50eca commit c2580db
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const updateState = require('../../common/state/updateState')
// Constants
const settings = require('../../../js/constants/settings')
const messages = require('../../../js/constants/messages')
const appConfig = require('../../../js/constants/appConfig')
const ledgerStatuses = require('../../common/constants/ledgerStatuses')

// Utils
Expand Down Expand Up @@ -866,7 +867,7 @@ const shouldTrackTab = (state, tabId) => {
}
const partition = tabFromState.get('partition', '')
const ses = session.fromPartition(partition)
const isPrivate = (ses && ses.isOffTheRecord()) || tabFromState.get('incognito')
const isPrivate = (ses && ses.isOffTheRecord()) || tabFromState.get('incognito') || partition === appConfig.tor.partition
return !isPrivate && !tabFromState.isEmpty() && ledgerUtil.shouldTrackView(tabFromState)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,6 @@ if (chrome.contentSettings.canvasFingerprinting == 'block') {
blockWebRTC()
}

if (chrome.contentSettings.torEnabled == 'block') {
if (isTorTab()) {
blockWebRTC()
}
4 changes: 2 additions & 2 deletions app/extensions/brave/content/scripts/blockFlash.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (adobeRegex.test(window.location.href)) {
}
}

if (chrome.contentSettings.flashEnabled == 'allow') {
if (chrome.contentSettings.flashEnabled == 'allow' && !isTorTab()) {
document.addEventListener('click', (e) => {
let node = e.target
while (!node.href && node.parentNode)
Expand All @@ -46,6 +46,6 @@ if (chrome.contentSettings.flashEnabled == 'allow') {
})
}

if (chrome.contentSettings.plugins != 'allow') {
if (chrome.contentSettings.plugins != 'allow' || isTorTab()) {
executeScript(getBlockFlashPageScript())
}
2 changes: 1 addition & 1 deletion app/extensions/brave/content/scripts/flashListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function hasHiddenFlashElement (elem) {

// If Flash is enabled but not runnable, show a permission notification for small
// Flash elements
if (chrome.contentSettings.flashEnabled == 'allow' && chrome.contentSettings.flashAllowed != 'allow') {
if (chrome.contentSettings.flashEnabled == 'allow' && chrome.contentSettings.flashAllowed != 'allow' && !isTorTab()) {
const maxFlashAttempts = 3
let flashAttempts = 0
const intervalId = window.setInterval(() => {
Expand Down
2 changes: 1 addition & 1 deletion app/extensions/brave/content/scripts/pageInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
if (window.top !== window.self) return

// Don't allow ledger to run in incognito
if (chrome.extension.inIncognitoContext) {
if (chrome.extension.inIncognitoContext || isTorTab()) {
return
}

Expand Down
4 changes: 4 additions & 0 deletions app/extensions/brave/content/scripts/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ function isPlatformOSX () {
function hasWhitespace (text) {
return /\s/g.test(text);
}

function isTorTab () {
return chrome.contentSettings.torEnabled != 'allow'
}

0 comments on commit c2580db

Please sign in to comment.