brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.83k stars 2.33k forks source link

[Desktop] Brave Shields causes createOffer/createAnswer to resolve to undefined when on IP domain #11141

Open t-mullen opened 4 years ago

t-mullen commented 4 years ago

Description

When Brave Shields is enabled, RTCPeerConnection.createOffer and RTCPeerConnection.createAnswer can resolve to undefined. The issue occurs when on an IP domain (e.g. 127.0.0.1 and possibly others).

Steps to Reproduce

  1. Enable Shields.
  2. Run the following script on the 127.0.0.1 domain (not localhost)
    var pc = new RTCPeerConnection({
    iceServers: [
    {
      urls: [
        'stun:stun.l.google.com:19302',
        'stun:global.stun.twilio.com:3478'
      ]
    }
    ],
    sdpSemantics: 'unified-plan'
    })
    pc.createOffer().then((offer) => {
    console.log('offer:', offer) // undefined, against specification
    })
    1. Disable Shields and refresh.
    2. Observe the above script no longer resolves to undefined.

Actual result:

Brave Shields breaks WebRTC on the 127.0.0.1 domain by causing these core WebRTC methods to resolve incorrectly.

Expected result:

Brave Shields should either reject these promises with an error or allow them to resolve correctly.

Reproduces how often:

Easily reproduced.

Brave version (brave://version info)

Version 1.10.97 Chromium: 83.0.4103.116 (Official Build) (64-bit) OSX

Version/Channel Information:

Other Additional Information:

Miscellaneous Information:

See discussion of this issue here https://github.com/feross/simple-peer/issues/701.

t-mullen commented 4 years ago

Updated issue to note that this behaviour is consistent when accessing 127.0.0.1 and possibly other IP domains.

cjwijtmans commented 4 years ago

localhost can also be ::1

rebron commented 4 years ago

cc: @jumde Can you take a look?