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

Issue 610646 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
hobby only
Closed: May 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 1
Type: Bug-Security



Sign in to add a comment

Bad-cast to const blink::WebPasswordCredential from blink::WebCredential;type_converters.cc:87:9

Project Member Reported by ClusterFuzz, May 10 2016

Issue description

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

Fuzzer: inferno_twister
Job Type: linux_ubsan_vptr_chrome
Platform Id: linux

Crash Type: Bad-cast
Crash Address: 0x7ffcea823420
Crash State:
  Bad-cast to const blink::WebPasswordCredential from blink::WebCredential
  type_converters.cc:87:9
  
Recommended Security Severity: High


Minimized Testcase (0.11 Kb):
Download: https://cluster-fuzz.appspot.com/download/AMIfv9522jjLcE1eMd6pCjKqyCgmoPrL4e4EyF1yN164rO_yWt7Aj_tG_BztxPaz5AvCz7Y8siZAaTXsE1aW9KCADLFZM9SBVP5Ix-ABLLzVTYTU_Wx86SowYb_1ZoDaH__BiD-CZcP9nXby9yjvyOHEmwkXNcnb_g
<script>
navigator.credentials.store(new PasswordCredential({'id': 'name', 'password': 'password' }))
</script>


Filer: mmoroz

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

Comment 1 by mmoroz@chromium.org, May 10 2016

Cc: mmoroz@chromium.org mbarbe...@chromium.org
Labels: M-51 Pri-1
Owner: vabr@chromium.org
vabr@, could you please help to find an owner for that?
Project Member

Comment 2 by ClusterFuzz, May 10 2016

Status: Assigned (was: Available)

Comment 3 by vabr@chromium.org, May 10 2016

Cc: mkwst@chromium.org vasi...@chromium.org
(Cc-ing CM API experts)

mmoroz@ -- do you know how much UBSAN's diagnostics can be trusted?

It says that the cast in the code snippet [1]:

const blink::WebCredential& input;
...
if (input.isPasswordCredential()) {
...
        static_cast<const blink::WebPasswordCredential&>(input)
...

The down-cast of |input| is invalid. But as long as |isPasswordCredential| is not crazy, that down-cast is valid.

[1] https://code.google.com/p/chromium/codesearch#chromium/src/components/password_manager/content/public/cpp/type_converters.cc&q=components/password_manager/content/public/cpp/type_converters.cc&sq=package:chromium&type=cs&l=80-87

Comment 4 by mmoroz@chromium.org, May 10 2016

Cc: kcc@chromium.org aizatsky@chromium.org
vabr@, I've heard that it may have false positives. Adding Kostya and Mike to take a look.
It seems pretty sure of a vptr value. How can this be false positive?

Does this issue reproduce? What does debugger say?
Components: Blink>Forms>Password

Comment 7 by vabr@chromium.org, May 11 2016

Status: Started (was: Assigned)
I did not manage to reproduce, so no debugger. But I now maybe understand the issue:
WebCredential is a wrapper around PlatformCredential. If WebCredential::isPasswordCredential says true, that means that that WebCredential wraps a PlatformPasswordCredential, but probably not that the wrapper itself is a WebPasswordCredential. I'll investigate more and will try to fix this.

Comment 8 by vabr@chromium.org, May 11 2016

So the code creates WebCredential around PlatformPasswordCredential somewhere, instead of creating WebPasswordCredential. This easily reproduces also by submitting the password form on https://w3c.github.io/webappsec/demos/credential-management/.

So UBSAN is correct, and found a bug in our code. Great job UBSAN and your creators!

I'll follow up with a patch of our code shortly.

Comment 9 by vabr@chromium.org, May 11 2016

The issue is that https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/platform/exported/WebCredential.cpp&l=17 does object slicing:
The create() method constructs a WebPasswordCredential variable and calls return on it. But the return type is WebCredential, so the compiler uses WC's copy constructor to slice away the sub-class part, and returns a proper WebCredential.
Project Member

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

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

commit 9818ab57e995473e2d41d5bb40b6a9abd2682151
Author: vabr <vabr@chromium.org>
Date: Wed May 11 17:01:30 2016

Avoid object slicing in WebCredential::create

WebCredential::create currently returns a WebCredential. It tries to create one
of its subclasses, WebPasswordCredential or WebFederatedCredential,
respectively, but those object get sliced to their common base upon returning,
because a function returning A cannot return B even if B is a subclass of A.

To fix that, this CL changes create() to return a pointer to a WebCredential.
This allows creating subclasses of it while keeping the return type as
declared.

R=mkwst@chromium.org
BUG= 610646 

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

[modify] https://crrev.com/9818ab57e995473e2d41d5bb40b6a9abd2682151/third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp
[modify] https://crrev.com/9818ab57e995473e2d41d5bb40b6a9abd2682151/third_party/WebKit/Source/platform/exported/WebCredential.cpp
[modify] https://crrev.com/9818ab57e995473e2d41d5bb40b6a9abd2682151/third_party/WebKit/public/platform/WebCredential.h

Comment 11 by vabr@chromium.org, May 12 2016

Status: Fixed (was: Started)
Project Member

Comment 13 by sheriffbot@chromium.org, May 12 2016

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

Comment 14 by ClusterFuzz, May 12 2016

Labels: Merge-Triage M-50
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-Request-XX label, where XX is the Chrome milestone.

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

Comment 15 by vabr@chromium.org, May 13 2016

Labels: Merge-Request-51
Requesting merge of r392959 to M51 (2704).

Comment 16 by vabr@chromium.org, May 13 2016

Labels: Merge-Request-50
Requesting merge of r392959 to M50 (2661).

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

Labels: -Merge-Request-50 Merge-Review-50 Hotlist-Merge-Review
[Automated comment] Request affecting a post-stable build (M50), manual review required.

Comment 18 by tin...@google.com, May 13 2016

Labels: -Merge-Request-51 Merge-Approved-51 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M51 (branch: 2704)

Comment 19 by tin...@google.com, May 13 2016

Labels: -Merge-Request-50 Merge-Review-50 Hotlist-Merge-Review
[Automated comment] Request affecting a post-stable build (M50), manual review required.
Project Member

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

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

commit a11ede2c9225b66ee9403f5bf26eceb11987afb6
Author: Vaclav Brozek <vabr@chromium.org>
Date: Fri May 13 11:43:23 2016

Avoid object slicing in WebCredential::create

WebCredential::create currently returns a WebCredential. It tries to create one
of its subclasses, WebPasswordCredential or WebFederatedCredential,
respectively, but those object get sliced to their common base upon returning,
because a function returning A cannot return B even if B is a subclass of A.

To fix that, this CL changes create() to return a pointer to a WebCredential.
This allows creating subclasses of it while keeping the return type as
declared.

R=mkwst@chromium.org
BUG= 610646 

Review-Url: https://codereview.chromium.org/1967693003
Cr-Commit-Position: refs/heads/master@{#392959}
(cherry picked from commit 9818ab57e995473e2d41d5bb40b6a9abd2682151)

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

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

[modify] https://crrev.com/a11ede2c9225b66ee9403f5bf26eceb11987afb6/third_party/WebKit/Source/modules/credentialmanager/CredentialsContainer.cpp
[modify] https://crrev.com/a11ede2c9225b66ee9403f5bf26eceb11987afb6/third_party/WebKit/Source/platform/exported/WebCredential.cpp
[modify] https://crrev.com/a11ede2c9225b66ee9403f5bf26eceb11987afb6/third_party/WebKit/public/platform/WebCredential.h

Comment 21 by vabr@chromium.org, May 13 2016

Labels: -M-50 -Merge-Triage -Hotlist-Merge-review -Merge-Review-50
go/betabuilders look fine after #20.

I am withdrawing the merge request for 50 based on these grounds:
(1) Credential manager API is not launched in 50. This code can only be triggered through Credential manager API.
(2) Version 51 enters stable really soon.
(3) I am not able to merge anything next week.
Labels: Release-0-M51
 Issue 605477  has been merged into this issue.
Project Member

Comment 24 by sheriffbot@chromium.org, Aug 18 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