New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 649118 link

Starred by 2 users

Issue metadata

Status: Archived
Owner:
Last visit > 30 days ago
Closed: Nov 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 1
Type: Bug-Security

Blocking:
issue 648971



Sign in to add a comment

TURN (via WebRTC) with via STUN_ERROR_TRY_ALTERNATE allows TCP connection with attacker-controlled data to localhost

Project Member Reported by rickyz@chromium.org, Sep 21 2016

Issue description

The exploit in  issue 648971  uses TURN (via WebRTC) to port scan and talk to shill (running an HTTP server on localhost)

1) Perhaps our TURN implementation should block redirection to localhost or internal IP ranges (would the latter break valid TURN functionality?)
2) TURN vs. HTTP Protocol confusion - shill's HTTP parser extremely lax, making the username field in the TURN message sufficient to talk to its HTTP interface.

 

Comment 1 by dgreid@chromium.org, Sep 21 2016

Cc: cernekee@chromium.org
Labels: Restrict-View-SecurityTeam
Adding View restriction
Cc: gzo...@gmail.com
Adding finder for the chain to CC list.
Cc: kirtika@chromium.org
Unfortunately I can't see  bug 648971 .

Why is shill running a web server?

Can we create iptables/ip6tables owner match rules to restrict web server access to a specific UID, or does it need to be accessed by chrome/chronos?
Shill is running a proxy server. 

https://chromium.googlesource.com/aosp/platform/system/connectivity/shill/+/master/http_proxy.h
// The HTTPProxy class implements a simple web proxy that
// is bound to a specific interface and name server.  This
// allows us to specify which connection a URL should be
// fetched through, even though many connections
// could be active at the same time.
//
// This service is meant to be low-performance, since we
// do not want to divert resources from the rest of the
// connection manager.  As such, we serve one client request
// at a time.  This is probably okay since the use case is
// limited -- only portal detection, activation and Cashew
// are planned to be full-time users.


Comment 6 by rickyz@chromium.org, Sep 23 2016

Cc: henrika@chromium.org
Hey henrika@, would you happen to be familiar with WebRTC's use of STUN/TURN (or know someone who is)? We received an exploit that uses a TURN request to a attacker-controlled server returning STUN_ERROR_TRY_ALTERNATE to trick Chrome into port scanning and connecting to a service listening on 127.0.0.1. By specifying a realm attribute in the response, they were able to get semi-controlled data (via the username field) sent to the local service to successfully exploit it.

I was wondering what kind of room we have to restrict what our TURN client is willing to connect to - at the very least, we can probably be pretty certain that a localhost alternate IP is illegal, right?

Comment 7 by gzo...@gmail.com, Sep 23 2016

STUN_ERROR_TRY_ALTERNATE is indeed used used to exploit shill once the port is known. I should clarify that it's not used for port scan. The first plan was to use it for port scan as well, but making an external TURN connection for each port to be scanned was too slow.

Port scan does also use TURN though. It attempts a connection to each localhost port directly. Multiple servers can be listed in iceServers and that's used to scan in blocks of 1024 ports. Once WebRTC is done attempting a connection to all the ports, it will call pc.onicecandidate({candidate: null}). A successful connection to shill is kept alive for 2.5 seconds. So the delay of the callback leaks whether the block contained the shill port. The connection is kept alive regardless of what TURN sends, as long as the HTTP headers are not terminated. That's why the alternate server trick is not necessary for scan.

Blocking a redirect to localhost STUN_ERROR_TRY_ALTERNATE would certainly block the exploit. Not sure if that's doable. It's also worth double checking whether it's valid for STUN_ERROR_TRY_ALTERNATE to specify the realm attribute. Perhaps it should be specified by the alternate server instead?

Cc: -henrika@chromium.org
Labels: -Pri-1 Security_Severity-Medium Security_Impact-Stable Pri-2
Owner: henrika@chromium.org
Status: Assigned (was: Available)
henrika@ - Please have a look at whether we can introduce a restriction here. Thanks!
Project Member

Comment 9 by sheriffbot@chromium.org, Sep 24 2016

Labels: M-54
Cc: pthatcher@chromium.org
Owner: hta@chromium.org
Re #8: I have not done any work on TURN, hence not really sure how my name popped up in this context.

hta@: can you find a more suitable owner?

Comment 11 by hta@chromium.org, Sep 26 2016

Cc: henrika@chromium.org

Comment 12 by hta@chromium.org, Sep 26 2016

Cc: -pthatcher@chromium.org hta@chromium.org
Owner: pthatcher@chromium.org
TURN work is mainly done out of Kirkland, I think. Reassigning to pthatcher.

Cc: honghaiz@chromium.org
Labels: WebRTCTriaged
Status: Available (was: Assigned)
It would be very easy to prevent STUN_ERROR_TRY_ALTERNATE from redirecting to localhost. And I can't think of any legitimate scenario where this would happen.

I have a question, though: Why is STUN_ERROR_TRY_ALTERNATE even necessary for the exploit? Couldn't you just add the localhost address to iceServers?
STUN_ERROR_TRY_ALTERNATE is needed because in the exploit, the controlled data came from the username field, and auth info (including the username) is only sent if a realm was previously received from the server:

https://cs.chromium.org/chromium/src/third_party/webrtc/p2p/base/turnport.cc?l=1071

hash_ is set by the UpdateHash call in set_realm, triggered via https://cs.chromium.org/chromium/src/third_party/webrtc/p2p/base/turnport.cc?l=1215

We should probably still ban direct connections to localhost as well though!
Ah, right. I forgot about that.


We could probably ban STUN/TRUN connections to localhost altogether... But that could break someone's testbed. So if we do that, I'd say we should do it separately from addressing this exploit.
Project Member

Comment 16 by sheriffbot@chromium.org, Oct 6 2016

pthatcher: Uh oh! This issue still open and hasn't been updated in the last 14 days. This is a serious vulnerability, and we want to ensure that there's progress. Could you please leave an update with the current status and any potential blockers?

If you're not the right owner for this issue, could you please remove yourself as soon as possible or help us find the right one?

If the issue is fixed or you can't reproduce it, please close the bug. If you've started working on a fix, please set the status to Started.

Thanks for your time! To disable nags, add the Disable-Nags label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 17 by sheriffbot@chromium.org, Oct 6 2016

Status: Assigned (was: Available)
Project Member

Comment 18 by sheriffbot@chromium.org, Oct 20 2016

pthatcher: Uh oh! This issue still open and hasn't been updated in the last 28 days. This is a serious vulnerability, and we want to ensure that there's progress. Could you please leave an update with the current status and any potential blockers?

If you're not the right owner for this issue, could you please remove yourself as soon as possible or help us find the right one?

If the issue is fixed or you can't reproduce it, please close the bug. If you've started working on a fix, please set the status to Started.

Thanks for your time! To disable nags, add the Disable-Nags label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: -henrika@chromium.org
Labels: -Pri-2 Pri-1
Increasing priority since this is a security exploit with a seemingly simple solution.
Project Member

Comment 21 by bugdroid1@chromium.org, Oct 24 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/external/webrtc.git/+/fb70b4503078503d7366f8cbe4928b2f437bd569

commit fb70b4503078503d7366f8cbe4928b2f437bd569
Author: deadbeef <deadbeef@webrtc.org>
Date: Mon Oct 24 20:15:59 2016

Preventing TURN redirects to loopback addresses.

This can be used for a certain security exploit, and doesn't have any
other practical applications we know of.

BUG= chromium:649118 

Review-Url: https://codereview.webrtc.org/2440043004
Cr-Commit-Position: refs/heads/master@{#14751}

[modify] https://crrev.com/fb70b4503078503d7366f8cbe4928b2f437bd569/webrtc/p2p/base/turnport.cc
[modify] https://crrev.com/fb70b4503078503d7366f8cbe4928b2f437bd569/webrtc/p2p/base/turnport_unittest.cc

Note: there's still one CL waiting to go in, fixing an "is loopback?" check.

Also, a question: In order to consider this "fixed", do we need to also block redirects to the machine's non-loopback addresses? This would certainly be possible, albeit a little more messy. But it seems less important than blocking redirects to loopback addresses, since a service listening on a non-loopback address is already vulnerable in some cases. Thoughts?
Project Member

Comment 23 by bugdroid1@chromium.org, Oct 28 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/external/webrtc.git/+/9922016ee44c70eb1c14f647cc4a5ade58a0018c

commit 9922016ee44c70eb1c14f647cc4a5ade58a0018c
Author: deadbeef <deadbeef@webrtc.org>
Date: Fri Oct 28 01:30:23 2016

Fix "IsLoopbackIp" to cover all loopback addresses; not just 127.0.0.1.

The loopback range is 127.0.0.0/8, which is everything from 127.0.0.0 to
127.255.255.255.

BUG= chromium:649118 

Review-Url: https://codereview.webrtc.org/2445933003
Cr-Commit-Position: refs/heads/master@{#14807}

[modify] https://crrev.com/9922016ee44c70eb1c14f647cc4a5ade58a0018c/webrtc/base/ipaddress.cc
[modify] https://crrev.com/9922016ee44c70eb1c14f647cc4a5ade58a0018c/webrtc/base/ipaddress_unittest.cc
[modify] https://crrev.com/9922016ee44c70eb1c14f647cc4a5ade58a0018c/webrtc/p2p/base/turnport_unittest.cc

Status: Fixed (was: Assigned)
Tentatively marking as fixed. Please reopen if you believe more redirects need to be blocked (see comment #22).
Project Member

Comment 25 by sheriffbot@chromium.org, Nov 9 2016

Labels: -Restrict-View-SecurityTeam Restrict-View-SecurityNotify
Project Member

Comment 26 by sheriffbot@chromium.org, Feb 15 2017

Labels: -Restrict-View-SecurityNotify allpublic
This bug has been closed for more than 14 weeks. Removing security view restrictions.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 27 by dchan@google.com, Mar 4 2017

Labels: VerifyIn-58

Comment 28 by dchan@google.com, Apr 17 2017

Labels: VerifyIn-59

Comment 29 by dchan@google.com, May 30 2017

Labels: VerifyIn-60
Labels: VerifyIn-61

Comment 31 by dchan@chromium.org, Oct 14 2017

Status: Archived (was: Fixed)

Sign in to add a comment