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
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]
Further upstream patch: https://github.com/kkos/oniguruma/commit/b4bf968
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.
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) ~~~
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
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.