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

Issue 622197 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Last visit > 30 days ago
Closed: Aug 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 3
Type: Bug-Security



Sign in to add a comment

Heap-buffer-overflow in u16_u8

Project Member Reported by ClusterFuzz, Jun 22 2016

Issue description

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

Fuzzer: libfuzzer_hunspell_fuzzer
Job Type: libfuzzer_chrome_asan
Platform Id: linux

Crash Type: Heap-buffer-overflow WRITE 1
Crash Address: 0x608000009ef8
Crash State:
  u16_u8
  Hunspell::mkinitcap
  Hunspell::suggest
  
Recommended Security Severity: High

Regressed: https://cluster-fuzz.appspot.com/revisions?job=libfuzzer_chrome_asan&range=401002:401127

Minimized Testcase (0.08 Kb):
Download: https://cluster-fuzz.appspot.com/download/AMIfv96-Onew44vdwTn_gq19R1runJsdl5uX14ZMq5Gutohd2D2-PmVTo-bGg7tw2HDg3ot3MfZARtJu725pLIoCeMgt0rhIqtq0dBZgwqU-BnrE-Ts4rkI_c7_OLb1PDLhTJU1O5x5VND87iBPdAPdg8cGLdOWtuQ?testcase_id=5520058793328640
R:<?xl<<?x(ml?>�<abuts?x�ml?>b<?xe?<}
:'�<abuts?xml?>b<?x-?->paralleldi!pe.Tselctionp


Filer: mmoroz

See https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/reproducing.md for more information.
 

Comment 1 by mmoroz@chromium.org, Jun 22 2016

Cc: mmoroz@chromium.org rouslan@chromium.org kcc@chromium.org aizatsky@chromium.org
Labels: Pri-1
Owner: groby@chromium.org
Project Member

Comment 2 by sheriffbot@chromium.org, Jun 22 2016

Labels: M-53
Project Member

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

Labels: ReleaseBlock-Beta
This issue is a security regression. If you are not able to fix this quickly, please revert the change that introduced it.

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

Comment 4 by ClusterFuzz, Jun 22 2016

Status: Assigned (was: Available)
Components: UI>Browser>Spellcheck

Comment 6 by groby@chromium.org, Jun 23 2016

See previous comments on  bug #622196  comment 5. 

In essence - the only way to fix this short term is to disable hunspell
Project Member

Comment 7 by sheriffbot@chromium.org, Jun 23 2016

Labels: M-53

Comment 8 by gov...@chromium.org, Jun 23 2016

M53 is branching soon and will be promoted to Beta in July.Your bug is labelled as Beta ReleaseBlock, pls make sure to land the fix ASAP. Thank you. 

Comment 9 by gov...@chromium.org, Jun 28 2016

M53 is branching this week and will be promoted to Beta in July.Your bug is labelled as Beta ReleaseBlock, pls make sure to land the fix ASAP. Thank you.
M53 is branched today (2785) and will be promoted to Beta this month.Your bug is labelled as Beta ReleaseBlock, pls make sure to land and merge the fix to M53 branch 2785 by 5:00 PM PST on Friday 07/22 (sooner the better so it gets chance to bake in M53 dev releases it self). Thank you.
Project Member

Comment 11 by sheriffbot@chromium.org, Jul 7 2016

groby: Uh oh! This issue still open and hasn't been updated in the last 14 days. This is a serious vulnerability, and we want to ensure that there's progress. Could you please leave an update with the current status and any potential blockers?

If you're not the right owner for this issue, could you please remove yourself as soon as possible or help us find the right one?

If the issue is fixed or you can't reproduce it, please close the bug. If you've started working on a fix, please set the status to Started.

Thanks for your time! To disable nags, add the Disable-Nags label.

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

Comment 12 by groby@chromium.org, Jul 12 2016

Can't build fuzzer on OSX. Created a manual test case[1], but that unfortunately doesn't crash, so still can't debug what's happening.

Should I be able to run fuzzer on OSX?

[1]https://codereview.chromium.org/2136333003/

Comment 13 by groby@chromium.org, Jul 12 2016

OK, here's the status so far.

It begins with the fuzzer creating invalid utf8. If you look at the testcase, byte 15 has the value 0xbd - that's an invalid utf8 encoding. 

Hunspell::suggest then calls Hunspell::mkinitcap, which is capitalizing the first letter. By converting it to UTF16, capitalizing the first letter, and converting back to UTF8. (I don't even).

Even better, it's trying to do that in place. Which would work, except 0xbd turns into 0xfffd (Unicode's "invalid char") when going to UTF16, and then into the two-byte sequence 0xff 0xfd when going back to UTF8. It's added a character, and so goes past the end.

The "proper" fix would be to validate that Hunspell::suggest rejects words with invalid UTF8 encoding. Practically, that's already guaranteed - its only caller reencodes the string into UTF8, and so we'll never encounter improper encoding in the wild.

I'm leaving it open for now, but definitely not Releaseblocker

Comment 14 by groby@chromium.org, Jul 12 2016

Labels: -Pri-1 -Security_Severity-High Pri-3

Comment 15 by ta...@google.com, Jul 13 2016

Labels: Security_Severity-High

Comment 16 by ta...@google.com, Jul 13 2016

Labels: -Security_Severity-High

Comment 17 by ta...@google.com, Jul 13 2016

Labels: -ReleaseBlock-Beta Security_Severity-Low

Comment 18 by groby@chromium.org, Jul 13 2016

Notes for the future - the direct fix would be updating mkinitcap to limit the output buffer to strlen(input)+1. It's a hack in terms of proper character handling, but prohibits any possible overflow.

Other fixes would sanitize Hunspell's input, but I don't think we should do that - Hunspell already assumes sanitized input, for performance reasons.

If we want to sanitize,the easiests fix would be in Hunspell::suggest, after calling cleanword2 and checking wl == 0

#if HUNSPELL_CHROME_CLIENT // Always utf8, no separate path needed.
  u16_u8(cw, MAXWORDUTF8LEN, unicw, nc);
  wl = strlen(cw);
  if (wl == 0) return 0;
#endif 

Which basically replaces the "clean" word with a UTF8-sanitized version of the clean word. (Otherwise, if you pass in e.g. 0xbd, it'll operate under the assumption that the word is only one char, and then the later mkinitcap blows up horribly, because it generates 3 bytes)

Another alternative would be modifying get_captype_utf8 to always return NOCAP if it encounters invalid unicode, so it'd avoid an unsafe routine. 


Project Member

Comment 19 by sheriffbot@chromium.org, Jul 21 2016

Labels: -Security_Impact-Head Security_Impact-Beta
Project Member

Comment 20 by ClusterFuzz, Jul 29 2016

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

Fuzzer: libfuzzer_hunspell_fuzzer
Job Type: libfuzzer_chrome_asan
Platform Id: linux

Crash Type: Heap-buffer-overflow WRITE 1
Crash Address: 0x60700000c8c7
Crash State:
  u16_u8
  Hunspell::mkinitcap
  Hunspell::suggest
  
Recommended Security Severity: High


Minimized Testcase (0.07 Kb):
Download: https://cluster-fuzz.appspot.com/download/AMIfv95uEu7ZpSV2rOrAgOgBEpGqAegPMI1lZqyx3khN2rRgbR0uM_Gf0kB1WtzYv2gCBYrPk2-7rrdh16RfbJqUFq9hLOypRPjDnetqGIj8EueNfubKgwCa-oVzg8hI-OFoSSG7Z3_lPwuIwgDzwUNgbQ3ImK5Asw?testcase_id=6609313942732800
K�er'diphongsrp-I-?>negbours�Froceding:,�emblrassing��ceedigIR.-----<?x,m


Filer: tanin

See https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/reproducing.md for more information.
Project Member

Comment 21 by ClusterFuzz, Aug 27 2016

ClusterFuzz has detected this issue as fixed in range 414871:414881.

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

Fuzzer: libfuzzer_hunspell_fuzzer
Job Type: libfuzzer_chrome_asan
Platform Id: linux

Crash Type: Heap-buffer-overflow WRITE 1
Crash Address: 0x608000009ef8
Crash State:
  u16_u8
  Hunspell::mkinitcap
  Hunspell::suggest
  
Recommended Security Severity: High

Regressed: https://cluster-fuzz.appspot.com/revisions?job=libfuzzer_chrome_asan&range=401002:401127
Fixed: https://cluster-fuzz.appspot.com/revisions?job=libfuzzer_chrome_asan&range=414871:414881

Minimized Testcase (0.08 Kb):
Download: https://cluster-fuzz.appspot.com/download/AMIfv96-Onew44vdwTn_gq19R1runJsdl5uX14ZMq5Gutohd2D2-PmVTo-bGg7tw2HDg3ot3MfZARtJu725pLIoCeMgt0rhIqtq0dBZgwqU-BnrE-Ts4rkI_c7_OLb1PDLhTJU1O5x5VND87iBPdAPdg8cGLdOWtuQ?testcase_id=5520058793328640
R:<?xl<<?x(ml?>�<abuts?x�ml?>b<?xe?<}
:'�<abuts?xml?>b<?x-?->paralleldi!pe.Tselctionp


See https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/reproducing.md 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 22 by ClusterFuzz, Aug 27 2016

ClusterFuzz has detected this issue as fixed in range 414871:414881.

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

Fuzzer: libfuzzer_hunspell_fuzzer
Job Type: libfuzzer_chrome_asan
Platform Id: linux

Crash Type: Heap-buffer-overflow WRITE 1
Crash Address: 0x60700000c8c7
Crash State:
  u16_u8
  Hunspell::mkinitcap
  Hunspell::suggest
  
Recommended Security Severity: High

Fixed: https://cluster-fuzz.appspot.com/revisions?job=libfuzzer_chrome_asan&range=414871:414881

Minimized Testcase (0.07 Kb):
Download: https://cluster-fuzz.appspot.com/download/AMIfv95uEu7ZpSV2rOrAgOgBEpGqAegPMI1lZqyx3khN2rRgbR0uM_Gf0kB1WtzYv2gCBYrPk2-7rrdh16RfbJqUFq9hLOypRPjDnetqGIj8EueNfubKgwCa-oVzg8hI-OFoSSG7Z3_lPwuIwgDzwUNgbQ3ImK5Asw?testcase_id=6609313942732800
K�er'diphongsrp-I-?>negbours�Froceding:,�emblrassing��ceedigIR.-----<?x,m


See https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/reproducing.md 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 23 by ClusterFuzz, Aug 27 2016

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

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

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

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

Comment 25 by sheriffbot@chromium.org, Dec 3 2016

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
Components: -UI>Browser>Spellcheck UI>Browser>Language>Spellcheck

Sign in to add a comment