New issue
Advanced search Search tips

Issue 778251 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Nov 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 1
Type: Bug-Security



Sign in to add a comment

InputScalesValid has a potential buffer overflow

Project Member Reported by courbet@google.com, Oct 25 2017

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36

Steps to reproduce the problem:
I don't have a reproduction case, I just stumbled upon that while reading code.

What is the expected behavior?

What went wrong?
InputScalesValid does:

```
size_t scales_size = static_cast<size_t>(input.size() / sizeof(float));
if (scales_size != expected.size())
  return false;
std::unique_ptr<float[]> scales(new float[scales_size]);
memcpy(scales.get(), input.data(), input.size());
```

This will write out of bounds if `input.size() % sizeof(float) != 4`.

I don't think this is a real issue, but the fix is trivial:

```
if (input.size() != expected.size() * sizeof(float))
  return false;
size_t scales_size = static_cast<size_t>(input.size() / sizeof(float));
std::unique_ptr<float[]> scales(new float[scales_size]);
memcpy(scales.get(), input.data(), scales_size * sizeof(float));
```

Did this work before? N/A 

Chrome version: 62.0.3202.62  Channel: stable
OS Version: 
Flash Version:
 
Cc: pkotw...@chromium.org
Components: UI>Browser>Themes

Comment 2 by palmer@chromium.org, Oct 31 2017

Cc: -pkotw...@chromium.org est...@chromium.org
Labels: -Pri-2 Security_Severity-High M-63 Security_Impact-Stable OS-Chrome OS-Mac OS-Windows Pri-1
Owner: pkotw...@chromium.org
Status: Assigned (was: Unconfirmed)
I think you meant this will write OOB if `input.size() % sizeof(float) != 0`, is that right?

If so, I might try to fix it like this:

```
  const size_t scales_size = input.size() / sizeof(float);
  if (scales_size != expected.size() || input.size() % sizeof(float) != 0) {
    return false;
  }
```

(Note that the `static_cast<size_t>` should be unnecessary; the type of the expression is already size_t.)

I wonder if there is some way to refactor this to avoid needing to do the allocation and memcpy... a question for another day, I suppose.

So, this would seem to be potential memory corruption in the browser process, which would normally be Critical. But the mitigating factor here is that the target would have to choose to install a maliciously-crafted theme, right? I.e. the attack surface is only accessible after significant user action?

Comment 3 by courbet@google.com, Oct 31 2017

I've provided a fix above that avoids the double conditional.

> So, this would seem to be potential memory corruption in the browser process, which would normally be Critical. But the mitigating factor here is that the target would have to choose to install a maliciously-crafted theme, right? I.e. the attack surface is only accessible after significant user action?

Yes, to be honest I don't think it would be easy to exploit, but it's so easy to fix...
We started doing the memcpy() here https://chromiumcodereview.appspot.com/10854074
Project Member

Comment 6 by bugdroid1@chromium.org, Nov 1 2017

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

commit 0aa1e66be68440b6966c8659c677d1a7ef2c200e
Author: Peter Kotwicz <pkotwicz@chromium.org>
Date: Wed Nov 01 19:57:26 2017

Fix potential buffer overflow in browser_theme_pack.cc

This CL fixes a potential buffer overflow in InputScalesValid()

BUG= 778251 

Change-Id: Iec1dfa3a7758e94cbcdf50006540334fefba451f
Reviewed-on: https://chromium-review.googlesource.com/747323
Reviewed-by: Chris Palmer <palmer@chromium.org>
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513229}
[modify] https://crrev.com/0aa1e66be68440b6966c8659c677d1a7ef2c200e/chrome/browser/themes/browser_theme_pack.cc

Status: Fixed (was: Assigned)
Project Member

Comment 8 by sheriffbot@chromium.org, Nov 4 2017

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

Comment 9 by sheriffbot@chromium.org, Nov 6 2017

Labels: Merge-Request-63
Project Member

Comment 10 by sheriffbot@chromium.org, Nov 6 2017

Labels: -Merge-Request-63 Merge-Review-63 Hotlist-Merge-Review
This bug requires manual review: M63 has already been promoted to the beta branch, so this requires manual review
Please contact the milestone owner if you have questions.
Owners: cmasso@(Android), cmasso@(iOS), gkihumba@(ChromeOS), govind@(Desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: awhalley@chromium.org
+awhalley@ for M63 merge review
govind@ - good for M53
Labels: -Merge-Review-63 Merge-Approved-63
Approving merge to M63 branch 3239 based on comment #12. Please merge ASAP so we can take it in for this week Beta release. Thank you.
Project Member

Comment 14 by bugdroid1@chromium.org, Nov 7 2017

Labels: -merge-approved-63 merge-merged-3239
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/7396961b911c6840d6e0a7e4591b6f93626cc406

commit 7396961b911c6840d6e0a7e4591b6f93626cc406
Author: Peter Kotwicz <pkotwicz@chromium.org>
Date: Tue Nov 07 18:53:57 2017

Fix potential buffer overflow in browser_theme_pack.cc

This CL fixes a potential buffer overflow in InputScalesValid()

BUG= 778251 

Change-Id: Iec1dfa3a7758e94cbcdf50006540334fefba451f
Reviewed-on: https://chromium-review.googlesource.com/747323
Reviewed-by: Chris Palmer <palmer@chromium.org>
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#513229}(cherry picked from commit 0aa1e66be68440b6966c8659c677d1a7ef2c200e)
Reviewed-on: https://chromium-review.googlesource.com/757222
Reviewed-by: Peter Kotwicz <pkotwicz@chromium.org>
Cr-Commit-Position: refs/branch-heads/3239@{#409}
Cr-Branched-From: adb61db19020ed8ecee5e91b1a0ea4c924ae2988-refs/heads/master@{#508578}
[modify] https://crrev.com/7396961b911c6840d6e0a7e4591b6f93626cc406/chrome/browser/themes/browser_theme_pack.cc

Labels: Release-0-M63
Project Member

Comment 16 by sheriffbot@chromium.org, Feb 9 2018

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

Comment 17 by sheriffbot@chromium.org, Mar 27 2018

Labels: -M-63 M-65

Sign in to add a comment