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

Issue 634797 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 634796
Owner: ----
Closed: Nov 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug-Regression



Sign in to add a comment

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

Project Member Reported by ClusterFuzz, Aug 5 2016

Issue description

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

Fuzzer: inferno_twister
Job Type: linux_ubsan_chrome
Platform Id: linux

Crash Type: Integer-overflow
Crash Address: 
Crash State:
  int WTF::toIntegralType<int, unsigned char>
  blink::HTMLOListElement::parseAttribute
  blink::Element::attributeChanged
  
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/AMIfv96gw3sdGDxVrngG2ag-hBAed1KlP3dwby3P9lBvfWCazmpcGl5pzeP4xTQyZQRt_9MsqH0KEUKf7gA7hEUO6nTWZ-fSgHGaLuDZmg5hcTHUvGMfyuA_yfQBpkP8OLzjbzvLnTINQQzj_jzNbiho0hZquACyOQ?testcase_id=5596678537347072
<ol start=-2147483648>


Issue manually filed by: ranjitkan

See https://dev.chromium.org/Home/chromium-security/bugs/reproducing-clusterfuzz-bugs for more information.
 
Cc: ranjitkan@chromium.org
Components: Tools>Test>FindIt>CorrectResult
Labels: -Pri-1 -Type-Bug M-54 Findit-for-crash Te-Logged Pri-2 Type-Bug-Regression
Owner: esprehn@chromium.org
Status: Assigned (was: Untriaged)
Author: esprehn
Project: chromium
Changelist: https://chromium.googlesource.com/chromium/src//+/7dc7c0fc073b84f3050726b52ceec1bbcb304ba3
Time: Fri Jun 10 04:35:59 2016
The CL last changed line 74 of file StringToNumber.cpp, which is stack frame 0.

@esprehn: Request you to please take a look into it. Please help us to reassign if not with respect to your change.

Thanks.!
Cc: jyasskin@chromium.org yutak@chromium.org
Components: Blink>Internals>WTF
Labels: -Pri-2 Pri-3
Owner: ----
Status: Available (was: Assigned)
The test case is just:
<ol start=-2147483648>

That regression range doesn't make sense, I don't know why it thinks that range. Maybe the clang roll?

Anyway CF thinks it's the code here:

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

        value = base * value + digitValue;

I'm not sure if this one is worth fixing, all browsers I tested (Safari, Chrome, Firefox) give the same output from doing document.querySelector("ol").start which is -2147483648 so they all convert the value into the same thing, which is the same as the text value. So if we overflow we apparently still get the right result.

That said this loop has this code in it:

        if (value > maxMultiplier || (value == maxMultiplier && digitValue > (integralMax % base) + isNegative))
            goto bye;

which seems like it's trying to compensate for overflow already? Maybe jyasskin@ or yutak@ know if we're doing something wrong here.
Cc: esprehn@chromium.org
If value == 214748364 and digitValue == 8 == 2147483647 % 10 + 1, then we don't goto bye, and we run value = base * value + digitValue, which overflows 2147483648 to -2147483648. Then the 'if (isNegative)' block negates that to its original value, which is another undefined overflow.
What would you recommend doing to fix it? :)

We could copy the range checking code from base:
https://cs.chromium.org/chromium/src/base/strings/string_number_conversions.cc?rcl=1470439186&l=226

we could also just switch to base's converter and use the StringPiece or StringPiece16 methods, but we'd need to fix the whitespace checks to be locale independent:

https://cs.chromium.org/chromium/src/base/strings/string_number_conversions.cc?rcl=1470439186&l=95

They're using isspace and iswspace, and we can't do that since it changes the web exposed behavior.
+1 for re-using code from base/.

https://cs.chromium.org/chromium/src/base/strings/string_number_conversions.h isn't designed to depend on the user's locale, so it's probably an improvement to remove naïve uses of isspace.
Labels: Pri-2
Dupe of 634796 ?
Mergedinto: 634796
Status: Duplicate (was: Available)
Project Member

Comment 10 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

Sign in to add a comment