Bug 1466736 (CVE-2017-9226) - CVE-2017-9226 oniguruma: Heap buffer overflow in next_state_val() during regular expression compilation
Summary: CVE-2017-9226 oniguruma: Heap buffer overflow in next_state_val() during regu...
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2017-9226
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 1466749 1466750 1466751 1466752 1466753 1554537 1788387 1788388 1788389
Blocks: 1466748 1491035
TreeView+ depends on / blocked
 
Reported: 2017-06-30 11:02 UTC by Adam Mariš
Modified: 2020-12-14 08:59 UTC (History)
49 users (show)

Fixed In Version: oniguruma 6.3.0, php 5.6.31, php 7.0.21, php 7.1.7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-08 03:15:50 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2018:1296 0 None None None 2018-05-03 05:07:04 UTC

Description Adam Mariš 2017-06-30 11:02:11 UTC
An issue was discovered in Oniguruma 6.2.0, as used in Oniguruma-mod in
Ruby through 2.4.1 and mbstring in PHP through 7.1.5. A heap
out-of-bounds write or read occurs in next_state_val() during regular
expression compilation. Octal numbers larger than 0xff are not handled
correctly in fetch_token() and fetch_token_in_cc(). A malformed regular
expression containing an octal number in the form of '\700' would
produce an invalid code point value larger than 0xff in
next_state_val(), resulting in an out-of-bounds write memory
corruption.
 
Upstream bug:

https://github.com/kkos/oniguruma/issues/55

Upstream patch:

https://github.com/kkos/oniguruma/commit/f015fbdd95f76438cd86366467bb2b39870dd7c6

Comment 1 Adam Mariš 2017-06-30 11:32:27 UTC
Created oniguruma tracking bugs for this issue:

Affects: epel-7 [bug 1466750]
Affects: fedora-all [bug 1466752]


Created php tracking bugs for this issue:

Affects: fedora-all [bug 1466751]


Created ruby tracking bugs for this issue:

Affects: fedora-all [bug 1466749]


Created ruby193-ruby tracking bugs for this issue:

Affects: openshift-1 [bug 1466753]

Comment 2 Doran Moppert 2017-07-31 04:49:25 UTC
Further upstream patch:

https://github.com/kkos/oniguruma/commit/b4bf968

Comment 3 Doran Moppert 2017-07-31 04:55:51 UTC
Exploiting this requires attacker control of the regular expression to be compiled.  By inserting invalid octal sequences, the attacker can cause the application to read or write a single word up to 256 bytes away from the intended target.  The writes seem to all pass through BIT_SET(), limiting the outcome of any exploit that manages to cause a write.

Comment 6 Vít Ondruch 2017-09-06 13:44:07 UTC
Ruby is not vulnerable according to upstream:

~~~
> CVE-2017-9226 https://github.com/kkos/oniguruma/issues/55

not affected.

% ruby <<'END'
str = '[\\6000'.force_encoding('KOI8-R')
Regexp.new(str).match('a')
END
Traceback (most recent call last):
        2: from -:2:in `<main>'
        1: from -:2:in `new'
-:2:in `initialize': invalid escape code: /[\6000/ (RegexpError)
~~~

Comment 8 errata-xmlrpc 2018-05-03 05:06:50 UTC
This issue has been addressed in the following products:

  Red Hat Software Collections for Red Hat Enterprise Linux 6
  Red Hat Software Collections for Red Hat Enterprise Linux 6.7 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 7
  Red Hat Software Collections for Red Hat Enterprise Linux 7.3 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 7.4 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 7.5 EUS

Via RHSA-2018:1296 https://access.redhat.com/errata/RHSA-2018:1296

Comment 9 Mark Cooper 2020-01-07 04:38:00 UTC
The above regular expression can cause a segfault or an ASAN heap buffer overflow with version 5.9.2 of oniguruma which is included in the following containers:
 - openshift4/ose-metering-hadoop
 - openshift4/ose-metering-hive
 - openshift4/ose-metering-presto

The above containers include oniguruma but do not use it. This includes faq and jq which are present in the above containers (depend on oniguruma) and are only used for initial setup/installation of the Operator.


Note You need to log in before you can comment on or make changes to this bug.