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

Commit

Permalink
Disable webrtc IP leaks when fp protection is on
Browse files Browse the repository at this point in the history
Fix #260

Auditors: @bbondy
  • Loading branch information
diracdeltas committed Jun 29, 2016
1 parent 4856893 commit 653e4db
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
25 changes: 24 additions & 1 deletion js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ const locale = require('../l10n')
const appConfig = require('../constants/appConfig')
const { getSiteSettingsForHostPattern } = require('../state/siteSettings')

const WEBRTC_DEFAULT = 'default'
const WEBRTC_DISABLE_NON_PROXY = 'disable_non_proxied_udp'
// Looks like Brave leaks true public IP from behind system proxy when this option
// is on.
// const WEBRTC_PUBLIC_ONLY = 'default_public_interface_only'

class Frame extends ImmutableComponent {
constructor () {
super()
Expand Down Expand Up @@ -85,7 +91,8 @@ class Frame extends ImmutableComponent {

shouldCreateWebview () {
return !this.webview || this.webview.allowRunningInsecureContent !== this.allowRunningInsecureContent() ||
!!this.webview.allowRunningPlugins !== this.allowRunningPlugins()
!!this.webview.allowRunningPlugins !== this.allowRunningPlugins() ||
this.webRTCPolicy !== this.getWebRTCPolicy()
}

allowRunningInsecureContent () {
Expand Down Expand Up @@ -250,6 +257,9 @@ class Frame extends ImmutableComponent {

componentDidUpdate (prevProps, prevState) {
const cb = () => {
if (this.webRTCPolicy !== this.getWebRTCPolicy()) {
this.webview.setWebRTCIPHandlingPolicy(this.getWebRTCPolicy())
}
this.webview.setActive(this.props.isActive)
this.handleShortcut()
this.webview.setZoomFactor(getZoomValuePercentage(this.zoomLevel) / 100)
Expand Down Expand Up @@ -801,6 +811,19 @@ class Frame extends ImmutableComponent {
this.webview.stopFindInPage('clearSelection')
}

get webRTCPolicy () {
return this.webview ? this.webview.getWebRTCIPHandlingPolicy() : WEBRTC_DEFAULT
}

getWebRTCPolicy () {
const braverySettings = this.props.frameBraverySettings
if (!braverySettings || braverySettings.get('fingerprintingProtection') !== true) {
return WEBRTC_DEFAULT
} else {
return WEBRTC_DISABLE_NON_PROXY
}
}

render () {
return <div
className={cx({
Expand Down
7 changes: 7 additions & 0 deletions js/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,12 @@ class Main extends ImmutableComponent {
return siteSettings.getSiteSettingsForURL(this.allSiteSettings, location)
}

frameBraverySettings (location) {
return Immutable.fromJS(siteSettings.activeSettings(this.frameSiteSettings(location),
this.props.appState,
appConfig))
}

get activeSiteSettings () {
return this.frameSiteSettings(this.activeRequestedLocation)
}
Expand Down Expand Up @@ -814,6 +820,7 @@ class Main extends ImmutableComponent {
flashInitialized={this.props.appState.get('flashInitialized')}
allSiteSettings={allSiteSettings}
frameSiteSettings={this.frameSiteSettings(frame.get('location'))}
frameBraverySettings={this.frameBraverySettings(frame.get('location'))}
enableNoScript={this.enableNoScript(this.frameSiteSettings(frame.get('location')))}
isPreview={frame.get('key') === this.props.windowState.get('previewFrameKey')}
isActive={FrameStateUtil.isFrameKeyActive(this.props.windowState, frame.get('key'))}
Expand Down

6 comments on commit 653e4db

@diracdeltas
Copy link
Member Author

Choose a reason for hiding this comment

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

follow-up: #2337

@bbondy
Copy link
Member

@bbondy bbondy commented on 653e4db Jun 30, 2016

Choose a reason for hiding this comment

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

++

@bridiver
Copy link
Collaborator

Choose a reason for hiding this comment

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

this causes problems for extension pages (and possibly others) because it reloads the webview. In particular it breaks LastPass

@bridiver
Copy link
Collaborator

Choose a reason for hiding this comment

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

also FYI - it should not be necessary to reload the webview to update webrtc. Let me know if that is not working because it should update the renderer process immediately.

@diracdeltas
Copy link
Member Author

Choose a reason for hiding this comment

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

@bridiver should be easy to fix. it's not a problem that the webview is reloaded when allowRunningPlugins changes? (needed for click to play)

@bridiver
Copy link
Collaborator

Choose a reason for hiding this comment

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

allowRunningPlugins can be changed in electron so that it doesn't require a webview reload, but it seems to be the webrtc change that is causing the problem and that shouldn't require a reload

Please sign in to comment.