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

Issue 605474 link

Starred by 0 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Apr 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 1
Type: Bug-Security



Sign in to add a comment

Bad-cast to net::QuicSpdySession from net::QuicSession;quic_spdy_stream.cc:41:3

Project Member Reported by ClusterFuzz, Apr 21 2016

Issue description

Detailed report: https://cluster-fuzz.appspot.com/testcase?key=6057680501735424

Fuzzer: meacer_extension_apis
Job Type: linux_ubsan_vptr_chrome
Platform Id: linux

Crash Type: Bad-cast
Crash Address: 0x0c3518634000
Crash State:
  Bad-cast to net::QuicSpdySession from net::QuicSession
  quic_spdy_stream.cc:41:3
  
Recommended Security Severity: High


Minimized Testcase (9.49 Kb): https://cluster-fuzz.appspot.com/download/AMIfv96UndiHO-JKMbDSkLYJX9Dd7xI70JLFI17KGf99i-GUJRyYLU06Fq8iBHCtpwjcfOiym8RB9_-MMT1PztaMQ-y-QKBO393SuZeRxhmag4cVbZ6xtaKvUKQX24bz7IGPcUZJe6SlcGBYgiJabUs4BBBtjPHREQ

Filer: mmoroz

See https://dev.chromium.org/Home/chromium-security/bugs/reproducing-clusterfuzz-bugs for more information.
 

Comment 1 by mmoroz@chromium.org, Apr 21 2016

Components: Internals>Network>QUIC
Labels: Pri-2
Owner: eroman@chromium.org
eroman@, could you please help to find an owner?
Project Member

Comment 2 by ClusterFuzz, Apr 21 2016

Labels: -Pri-2 Pri-1
Status: Assigned (was: Available)

Comment 3 by eroman@chromium.org, Apr 21 2016

Cc: eroman@chromium.org
Owner: rch@chromium.org
Ryan, can you find an owner for this?

Comment 4 by eroman@chromium.org, Apr 21 2016

Specifically this looks like a double-free of ReliableQuicStream, because both the QuicSession and QuicStreamFactory::OnSessionClosed() think they own it.

Specific sequence of events in this crash:

(1) QuicStreamFactory::OnSessionClosed() deletes its |session_|. [1]

(2) The destructors for |session_| run -- it is of type QuicChromiumClientSession, so runs super class dtors in sequence ~QuicClientSessionBase -> ~QuicSpdySession -> ~QuicSession.

(3) When executing the ~QuicSession the pointers in |closed_stream_| are freed. [2]

(4) One of the pointers in |closed_stream_| is presumably the same QuicChromiumClientSession() that OnSessionClosed() is currently deleting. Hence we get a double-free, which in this report labels as a type mismatch (because the vtables are being modified as the various dtors run). B00M!

[1]  https://code.google.com/p/chromium/codesearch#chromium/src/net/quic/quic_stream_factory.cc&sq=package:chromium&type=cs&l=1188

[2] https://code.google.com/p/chromium/codesearch#chromium/src/net/quic/quic_session.cc&sq=package:chromium&type=cs&l=60

Comment 5 by vakh@chromium.org, Apr 21 2016

Labels: M-50

Comment 6 by rch@chromium.org, Apr 22 2016

Owner: jri@chromium.org
Nice catch! jri: can you take a look at this?

Comment 7 by jri@chromium.org, Apr 22 2016

Cc: rch@chromium.org

Comment 8 by rch@chromium.org, Apr 22 2016



On Thu, Apr 21, 2016 at 10:04 AM, eroman@chromium.org via Monorail <monorail@chromium.org> wrote:
>
>
> Comment #4 on  issue 605474  by eroman@chromium.org: Bad-cast to net::QuicSpdySession from net::QuicSession;quic_spdy_stream.cc:41:3
> https://bugs.chromium.org/p/chromium/issues/detail?id=605474#c4
>
> Specifically this looks like a double-free of ReliableQuicStream, because both the QuicSession and QuicStreamFactory::OnSessionClosed() think they own it.
>
> Specific sequence of events in this crash:
>
> (1) QuicStreamFactory::OnSessionClosed() deletes its |session_|. [1]
>
> (2) The destructors for |session_| run -- it is of type QuicChromiumClientSession, so runs super class dtors in sequence ~QuicClientSessionBase -> ~QuicSpdySession -> ~QuicSession.
>
> (3) When executing the ~QuicSession the pointers in |closed_stream_| are freed. [2]
>
> (4) One of the pointers in |closed_stream_| is presumably the same QuicChromiumClientSession() that OnSessionClosed() is currently deleting. Hence we get a double-free, which in this report labels as a type mismatch (because the vtables are being modified as the various dtors run). B00M!


I'm not sure I follow this completely. The object deleted in (1) is a session, but the object deleted in (4) is a stream (not a session). So that doesn't sound like a double delete. Of course, clearly there's a bug here, but I don't yet see the sequence of events that leads to it.

Comment 9 by eroman@chromium.org, Apr 22 2016

RE comment #8:

Sorry yes, I got tripped up by all of the class hierarchies, and missed a step at the end!


So in step (4) when freeing |closed_stream_|, it deletes a (ReliableQuicStream), which is of type QuicSpdyStream. That object has a (non-owned) pointer back to the *session* which is currently in the process of being destroyed:

QuicSpdyStream::~QuicSpdyStream() {
  spdy_session_->UnregisterStreamPriority(id());
}

So in this last step calling UnregisterStreamPriority() is effectively a use-after-free (not a double free as I earlier said).

Does that seem more plausible?
Project Member

Comment 10 by sheriffbot@chromium.org, Apr 22 2016

Labels: -Security_Impact-Head Security_Impact-Stable

Comment 11 by rch@chromium.org, Apr 22 2016

That sounds totally right... and rather disturbing :(

Thanks.
Project Member

Comment 12 by bugdroid1@chromium.org, Apr 29 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4ee9d76953f16811186942971822cf12d48db7ae

commit 4ee9d76953f16811186942971822cf12d48db7ae
Author: jri <jri@chromium.org>
Date: Fri Apr 29 02:04:35 2016

Fixes use-after-free bug in QUIC.

QuicSession destructor ends up calling the QuicSpdyStream destructor, which in turn tries to access a QuicSession method via a non-owning pointer back to the session. This CL arranges for the non-owning pointer to be set to null before QuicSpdyStream destructor is called.

Merge Internal CL: 120973813

Creates a MockQuicSession for use in ReliableQuicStreamTest, which currently incorrectly uses a MockQuicSpdySession.

The test class being fixed in this CL uses a MockQuicSpdySession, which is a QuicSpdySession, with TestStreams, which are ReliableQuicStreams. Bad things can happen since QuicSpdySession seems to freely assume that its streams are QuicSpdyStreams. Bad things do happen, but they inexplicably seem to show up only in Chromium tests.

Merge Internal CL: 120989117

BUG= 605474 

Review-Url: https://codereview.chromium.org/1932653002
Cr-Commit-Position: refs/heads/master@{#390575}

[modify] https://crrev.com/4ee9d76953f16811186942971822cf12d48db7ae/net/quic/quic_session_test.cc
[modify] https://crrev.com/4ee9d76953f16811186942971822cf12d48db7ae/net/quic/quic_spdy_session.cc
[modify] https://crrev.com/4ee9d76953f16811186942971822cf12d48db7ae/net/quic/quic_spdy_stream.cc
[modify] https://crrev.com/4ee9d76953f16811186942971822cf12d48db7ae/net/quic/quic_spdy_stream.h
[modify] https://crrev.com/4ee9d76953f16811186942971822cf12d48db7ae/net/quic/reliable_quic_stream_test.cc
[modify] https://crrev.com/4ee9d76953f16811186942971822cf12d48db7ae/net/quic/test_tools/quic_session_peer.cc
[modify] https://crrev.com/4ee9d76953f16811186942971822cf12d48db7ae/net/quic/test_tools/quic_session_peer.h
[modify] https://crrev.com/4ee9d76953f16811186942971822cf12d48db7ae/net/quic/test_tools/quic_test_utils.cc
[modify] https://crrev.com/4ee9d76953f16811186942971822cf12d48db7ae/net/quic/test_tools/quic_test_utils.h

Comment 13 by jri@chromium.org, Apr 29 2016

Status: Fixed (was: Assigned)
mmoroz: this should be fixed. can you verify using the fuzzer?
Project Member

Comment 14 by ClusterFuzz, Apr 30 2016

Labels: -Restrict-View-SecurityTeam Merge-Triage M-51 Restrict-View-SecurityNotify
Adding Merge-Triage label for tracking purposes.

Once your fix had sufficient bake time (on canary, dev as appropriate), please nominate your fix for merge by adding the Merge-Requested label.

When your merge is approved by the release manager, please start merging with higher milestone label first. Make sure to re-request merge for every milestone in the label list. You can get branch information on omahaproxy.appspot.com.

- Your friendly ClusterFuzz
jri@, thanks! Actually ClusterFuzz should check it automatically.
Labels: -Merge-Triage Merge-Request-51

Comment 17 by tin...@google.com, May 9 2016

Labels: -Merge-Request-51 Merge-Approved-51 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M51 (branch: 2704)
Please merge your change to M51 branch 2704 ASAP (before 5:00 PM PST today). So we can take it for this week beta release tomorrow. Thank you.
Project Member

Comment 19 by bugdroid1@chromium.org, May 11 2016

Labels: -merge-approved-51 merge-merged-2704
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/72c4e825fc4c65a8898ac3b3bf53092aba9787e3

commit 72c4e825fc4c65a8898ac3b3bf53092aba9787e3
Author: jri <jri@chromium.org>
Date: Wed May 11 21:43:46 2016

Fixes use-after-free bug in QUIC.

QuicSession destructor ends up calling the QuicSpdyStream destructor, which in turn tries to access a QuicSession method via a non-owning pointer back to the session. This CL arranges for the non-owning pointer to be set to null before QuicSpdyStream destructor is called.

Merge Internal CL: 120973813

Creates a MockQuicSession for use in ReliableQuicStreamTest, which currently incorrectly uses a MockQuicSpdySession.

The test class being fixed in this CL uses a MockQuicSpdySession, which is a QuicSpdySession, with TestStreams, which are ReliableQuicStreams. Bad things can happen since QuicSpdySession seems to freely assume that its streams are QuicSpdyStreams. Bad things do happen, but they inexplicably seem to show up only in Chromium tests.

Merge Internal CL: 120989117

BUG= 605474 
NOTRY=true
NOPRESUBMIT=true
Review-Url: https://codereview.chromium.org/1932653002
Cr-Commit-Position: refs/heads/master@{#390575}
(cherry picked from commit 4ee9d76953f16811186942971822cf12d48db7ae)

Review-Url: https://codereview.chromium.org/1975483003
Cr-Commit-Position: refs/branch-heads/2704@{#505}
Cr-Branched-From: 6e53600def8f60d8c632fadc70d7c1939ccea347-refs/heads/master@{#386251}

[modify] https://crrev.com/72c4e825fc4c65a8898ac3b3bf53092aba9787e3/net/quic/quic_session_test.cc
[modify] https://crrev.com/72c4e825fc4c65a8898ac3b3bf53092aba9787e3/net/quic/quic_spdy_session.cc
[modify] https://crrev.com/72c4e825fc4c65a8898ac3b3bf53092aba9787e3/net/quic/quic_spdy_stream.cc
[modify] https://crrev.com/72c4e825fc4c65a8898ac3b3bf53092aba9787e3/net/quic/quic_spdy_stream.h
[modify] https://crrev.com/72c4e825fc4c65a8898ac3b3bf53092aba9787e3/net/quic/reliable_quic_stream_test.cc
[modify] https://crrev.com/72c4e825fc4c65a8898ac3b3bf53092aba9787e3/net/quic/test_tools/quic_session_peer.cc
[modify] https://crrev.com/72c4e825fc4c65a8898ac3b3bf53092aba9787e3/net/quic/test_tools/quic_session_peer.h
[modify] https://crrev.com/72c4e825fc4c65a8898ac3b3bf53092aba9787e3/net/quic/test_tools/quic_test_utils.cc
[modify] https://crrev.com/72c4e825fc4c65a8898ac3b3bf53092aba9787e3/net/quic/test_tools/quic_test_utils.h

Project Member

Comment 20 by bugdroid1@chromium.org, May 12 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/90daabce88e115895b4912adc84f79269715d227

commit 90daabce88e115895b4912adc84f79269715d227
Author: jbudorick <jbudorick@chromium.org>
Date: Thu May 12 01:36:49 2016

Revert of Fixes use-after-free bug in QUIC. (patchset #1 id:1 of https://codereview.chromium.org/1975483003/ )

Reason for revert:
breaks M51: https://bugs.chromium.org/p/chromium/issues/detail?id=611267

Original issue's description:
> Fixes use-after-free bug in QUIC.
>
> QuicSession destructor ends up calling the QuicSpdyStream destructor, which in turn tries to access a QuicSession method via a non-owning pointer back to the session. This CL arranges for the non-owning pointer to be set to null before QuicSpdyStream destructor is called.
>
> Merge Internal CL: 120973813
>
> Creates a MockQuicSession for use in ReliableQuicStreamTest, which currently incorrectly uses a MockQuicSpdySession.
>
> The test class being fixed in this CL uses a MockQuicSpdySession, which is a QuicSpdySession, with TestStreams, which are ReliableQuicStreams. Bad things can happen since QuicSpdySession seems to freely assume that its streams are QuicSpdyStreams. Bad things do happen, but they inexplicably seem to show up only in Chromium tests.
>
> Merge Internal CL: 120989117
>
> BUG= 605474 
> NOTRY=true
> NOPRESUBMIT=true
> Review-Url: https://codereview.chromium.org/1932653002
> Cr-Commit-Position: refs/heads/master@{#390575}
> (cherry picked from commit 4ee9d76953f16811186942971822cf12d48db7ae)

TBR=rch@chromium.org,jri@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG= 605474 

Review-Url: https://codereview.chromium.org/1970073002
Cr-Commit-Position: refs/branch-heads/2704@{#514}
Cr-Branched-From: 6e53600def8f60d8c632fadc70d7c1939ccea347-refs/heads/master@{#386251}

[modify] https://crrev.com/90daabce88e115895b4912adc84f79269715d227/net/quic/test_tools/quic_session_peer.cc

Project Member

Comment 21 by bugdroid1@chromium.org, May 12 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a704d1d6340b468962bf4a93ac591e64eefbe175

commit a704d1d6340b468962bf4a93ac591e64eefbe175
Author: John Budorick <jbudorick@chromium.org>
Date: Thu May 12 01:54:00 2016

Revert "Revert of Fixes use-after-free bug in QUIC. (patchset #1 id:1 of https://codereview.chromium.org/1975483003/ )"

This reverts commit 90daabce88e115895b4912adc84f79269715d227.

CL had already been reverted in cd9116b59af4a885eb335b794b7a7b3a15d82b36

BUG= 605474 ,611267
TBR=

Review URL: https://codereview.chromium.org/1972813002 .

Cr-Commit-Position: refs/branch-heads/2704@{#515}
Cr-Branched-From: 6e53600def8f60d8c632fadc70d7c1939ccea347-refs/heads/master@{#386251}

[modify] https://crrev.com/a704d1d6340b468962bf4a93ac591e64eefbe175/net/quic/test_tools/quic_session_peer.cc

Project Member

Comment 22 by bugdroid1@chromium.org, May 12 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/af5cec5668c4dd03318ca5b31e100fb76f2959fb

commit af5cec5668c4dd03318ca5b31e100fb76f2959fb
Author: jri <jri@chromium.org>
Date: Thu May 12 22:40:40 2016

Fixes use-after-free bug in QUIC.

QuicSession destructor ends up calling the QuicSpdyStream destructor, which in turn tries to access a QuicSession method via a non-owning pointer back to the session. This CL arranges for the non-owning pointer to be set to null before QuicSpdyStream destructor is called.

Merge Internal CL: 120973813

Creates a MockQuicSession for use in ReliableQuicStreamTest, which currently incorrectly uses a MockQuicSpdySession.

The test class being fixed in this CL uses a MockQuicSpdySession, which is a QuicSpdySession, with TestStreams, which are ReliableQuicStreams. Bad things can happen since QuicSpdySession seems to freely assume that its streams are QuicSpdyStreams. Bad things do happen, but they inexplicably seem to show up only in Chromium tests.

Merge Internal CL: 120989117

BUG= 605474 
NOTRY=true
NOPRESUBMIT=true
Review-Url: https://codereview.chromium.org/1932653002
Cr-Commit-Position: refs/heads/master@{#390575}
(cherry picked from commit 4ee9d76953f16811186942971822cf12d48db7ae)

Review-Url: https://codereview.chromium.org/1975483003
Cr-Commit-Position: refs/branch-heads/2704@{#528}
Cr-Branched-From: 6e53600def8f60d8c632fadc70d7c1939ccea347-refs/heads/master@{#386251}

[modify] https://crrev.com/af5cec5668c4dd03318ca5b31e100fb76f2959fb/net/quic/quic_session_test.cc
[modify] https://crrev.com/af5cec5668c4dd03318ca5b31e100fb76f2959fb/net/quic/quic_spdy_session.cc
[modify] https://crrev.com/af5cec5668c4dd03318ca5b31e100fb76f2959fb/net/quic/quic_spdy_stream.cc
[modify] https://crrev.com/af5cec5668c4dd03318ca5b31e100fb76f2959fb/net/quic/quic_spdy_stream.h
[modify] https://crrev.com/af5cec5668c4dd03318ca5b31e100fb76f2959fb/net/quic/reliable_quic_stream_test.cc
[modify] https://crrev.com/af5cec5668c4dd03318ca5b31e100fb76f2959fb/net/quic/test_tools/quic_session_peer.cc
[modify] https://crrev.com/af5cec5668c4dd03318ca5b31e100fb76f2959fb/net/quic/test_tools/quic_session_peer.h
[modify] https://crrev.com/af5cec5668c4dd03318ca5b31e100fb76f2959fb/net/quic/test_tools/quic_test_utils.cc
[modify] https://crrev.com/af5cec5668c4dd03318ca5b31e100fb76f2959fb/net/quic/test_tools/quic_test_utils.h

Labels: Release-0-M51
Project Member

Comment 24 by sheriffbot@chromium.org, Aug 6 2016

Labels: -Restrict-View-SecurityNotify
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
Project Member

Comment 25 by sheriffbot@chromium.org, Oct 1 2016

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
Project Member

Comment 26 by sheriffbot@chromium.org, Oct 2 2016

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
Labels: allpublic

Sign in to add a comment