New issue
Advanced search Search tips

Issue 665110 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: Dec 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

Integer-overflow in int WTF::toIntegralType<int, unsigned char>

Project Member Reported by ClusterFuzz, Nov 14 2016

Issue description

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

Fuzzer: ifratric-browserfuzzer-v3
Job Type: linux_ubsan_chrome
Platform Id: linux

Crash Type: Integer-overflow
Crash Address: 
Crash State:
  int WTF::toIntegralType<int, unsigned char>
  blink::HTMLHRElement::collectStyleForPresentationAttribute
  blink::computePresentationAttributeStyle
  
Regressed: https://cluster-fuzz.appspot.com/revisions?job=linux_ubsan_chrome&range=370022:370027

Minimized Testcase (0.02 Kb):
Download: https://cluster-fuzz.appspot.com/download/AMIfv95Z1oGTJEJCdamsdcj1GZyTAlwuq9pGS3_kbGeDqh_UPZ_waBWGSbyuO_SN_8xqlyG1q63yiSC-FEIq2VATUyeKz-PMn613bzIWvMHjC3RjAJvYNT6I4sP2mMeLmSPNEehFoyhnKbrXogy0QIsowjo28REq6w?testcase_id=4949181631561728
<hr size="-2147483648">


Issue filed automatically.

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

Comment 1 by ajha@chromium.org, Nov 22 2016

Labels: M-55
Components: Blink>CSS
Project Member

Comment 3 by sheriffbot@chromium.org, Nov 22 2016

Labels: -Restrict-View-EditIssue
Removing EditIssue view restrictions from ClusterFuzz filed bugs. If you believe that this issue should still be restricted, please reapply the label.

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

Comment 4 by shans@chromium.org, Nov 22 2016

Status: Available (was: Untriaged)
Labels: Test-Predator-Wrong-CLs
Owner: esprehn@chromium.org
Status: Assigned (was: Available)
Unable to find the possible suspect using CL and Find it.
Using Code Search for the file, "StringToNumber.cpp" assigning to the concern owner.
Suspecting the Commit# 
https://chromium.googlesource.com/chromium/src/+/7dc7c0fc073b84f3050726b52ceec1bbcb304ba3

@esprehn -- Could you please look into the issue, kindly re-assign if this is not related to your change.
Thank You.
Cc: esprehn@chromium.org
Owner: yutak@chromium.org
There is overflow protection in there...

https://cs.chromium.org/chromium/src/third_party/WebKit/Source/wtf/text/StringToNumber.cpp?q=StringToNumber.cpp&sq=package:chromium&l=73

yutak@ Got ideas what's wrong with it?

Comment 7 by yutak@chromium.org, Dec 8 2016

Components: -Blink>CSS Blink>Internals>WTF
Status: Started (was: Assigned)
OK, sounds like this code has an issue with inputs like INT_MIN. For base 10,
it still gives the correct answer, even though an integer overflow has occurred.
(For base 16, it doesn't give a correct answer.)

It's a bit tricky but let me try to fix this.


Project Member

Comment 8 by bugdroid1@chromium.org, Dec 9 2016

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

commit 957b5b3085eeae5a6fd6779d62feb90cc2515ad2
Author: yutak <yutak@chromium.org>
Date: Fri Dec 09 09:53:17 2016

StringToNumber: Fix integer overflow on parsing INT_MIN.

This patch adjusts the algorithm of toIntegralType(), which parses an integer
value out of a string. Previously, toIntegralType() used a positive number
as an accumulator regardless of whether we had seen the negative sign or not,
and it inverted the accumulator value if there had been a negative sign. This
causes an integer overflow when INT_MIN is specified as the source string,
because the absolute value of INT_MIN is one larger than that of INT_MAX.

This patch fixes this issue by accumulating a negative value if the result
will be negative. Also, the detection algorithm of overflows is updated so
that it can detect overflows correctly in every possible case (it used to have
a small bug that the function fails to parse INT_MIN in base 16).

Additionally, unit tests are added.

BUG= 665110 

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

[modify] https://crrev.com/957b5b3085eeae5a6fd6779d62feb90cc2515ad2/third_party/WebKit/Source/wtf/BUILD.gn
[modify] https://crrev.com/957b5b3085eeae5a6fd6779d62feb90cc2515ad2/third_party/WebKit/Source/wtf/text/StringToNumber.cpp
[add] https://crrev.com/957b5b3085eeae5a6fd6779d62feb90cc2515ad2/third_party/WebKit/Source/wtf/text/StringToNumberTest.cpp

Comment 9 by f...@opera.com, Dec 9 2016

Cc: f...@opera.com pdr@chromium.org
 Issue 661640  has been merged into this issue.
Project Member

Comment 10 by ClusterFuzz, Dec 14 2016

ClusterFuzz has detected this issue as fixed in range 435261:438085.

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

Fuzzer: ifratric-browserfuzzer-v3
Job Type: linux_ubsan_chrome
Platform Id: linux

Crash Type: Integer-overflow
Crash Address: 
Crash State:
  int WTF::toIntegralType<int, unsigned char>
  blink::HTMLHRElement::collectStyleForPresentationAttribute
  blink::computePresentationAttributeStyle
  
Regressed: https://cluster-fuzz.appspot.com/revisions?job=linux_ubsan_chrome&range=370022:370027
Fixed: https://cluster-fuzz.appspot.com/revisions?job=linux_ubsan_chrome&range=435261:438085

Minimized Testcase (0.02 Kb):
Download: https://cluster-fuzz.appspot.com/download/AMIfv95Z1oGTJEJCdamsdcj1GZyTAlwuq9pGS3_kbGeDqh_UPZ_waBWGSbyuO_SN_8xqlyG1q63yiSC-FEIq2VATUyeKz-PMn613bzIWvMHjC3RjAJvYNT6I4sP2mMeLmSPNEehFoyhnKbrXogy0QIsowjo28REq6w?testcase_id=4949181631561728
<hr size="-2147483648">


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

If you suspect that the result above is incorrect, try re-doing that job on the test case report page.
Project Member

Comment 11 by ClusterFuzz, Dec 14 2016

Labels: ClusterFuzz-Verified
Status: Verified (was: Started)
ClusterFuzz testcase 4949181631561728 is verified as fixed, so closing issue.

If this is incorrect, please add ClusterFuzz-Wrong label and re-open the issue.

Sign in to add a comment