Bug 1466740 (CVE-2017-9228)

Summary: CVE-2017-9228 oniguruma: Out-of-bounds heap write in bitset_set_range()
Product: [Other] Security Response Reporter: Adam Mariš <amaris>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: bkearney, cbillett, ccoleman, cpelland, dajohnso, dedgar, dmcphers, dominik.mierzejewski, fedora, gblomqui, gmccullo, gtanzill, hhorak, hhudgeon, jfrey, jgoulding, jhardy, jorton, jprause, ktdreyer, mtasaka, no1youknowz, obarenbo, psampaio, rbeyel, rcollet, roliveri, ruby-maint, simaishi, s, strzibny, tomckay, vanmeeuwen+fedora, vondruch, webstack-team, yozone
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: impact=moderate,public=20170523,reported=20170524,source=cve,cvss3=5.9/CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H,cwe=CWE-122,rhel-5/php=wontfix,rhel-5/php53=wontfix,rhel-6/php=wontfix,rhel-6/oniguruma=wontfix,rhel-7/php=wontfix,rhscl-2/rh-php56-php=wontfix,rhscl-3/rh-php70-php=affected,rhel-5/ruby=wontfix,rhel-6/ruby=wontfix,rhel-7/ruby=wontfix,cfme-5/rh-ruby22-ruby=new,cfme-5/ruby-200-ruby=new,rhscl-2/rh-ruby23-ruby=wontfix,rhscl-2/rh-ruby22-ruby=wontfix,rhscl-2/rh-ruby24-ruby=wontfix,sam-1/ruby193-ruby=new,openshift-1/ruby193-ruby=affected,fedora-all/ruby=affected,fedora-all/php=affected,fedora-all/oniguruma=affected,epel-7/oniguruma=affected
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:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-08 03:15:54 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On: 1466750, 1466749, 1466751, 1466752, 1466753, 1554537    
Bug Blocks: 1466748, 1491035    

Description Adam Mariš 2017-06-30 11:16:28 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 occurs in bitset_set_range() during regular
expression compilation due to an uninitialized variable from an
incorrect state transition. An incorrect state transition in
parse_char_class() could create an execution path that leaves a
critical local variable uninitialized until it's used as an index,
resulting in an out-of-bounds write memory corruption. 
Upstream bug:


Upstream patch:


Comment 1 Adam Mariš 2017-06-30 11:34:23 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:26:35 UTC
Note also the second upstream patch:


Comment 3 Doran Moppert 2017-07-31 06:10:07 UTC
The attack demonstrated here gives very limited control - it looks like in the best case, up to 8 bits in a range determined by uninitialised (stack) data can be set to 1.

Comment 4 Vít Ondruch 2017-09-06 13:45:57 UTC
Ruby is not vulnerable according to upstream:

> CVE-2017-9228 https://github.com/kkos/oniguruma/issues/60

not affected.

% ruby <<'END'
str = [ 0xc7, 0xd6, 0xfe, 0xea, 0xe0, 0xe2, 0x00 ].pack('c*')
pattern = "\x5b\x5c\x48\x2d\xb0\x30\x8d\x30\x2a\x5b\x5d\x20\x20\x5d" +
          "\xf9\x54\x00\x7f\x5c\x63\xef\xef\xef\xef\x52\xf7\xf7\x52" +
re = Regexp.new(pattern.force_encoding('GB18030'), Regexp::IGNORECASE)
re.match str.force_encoding('GB18030')
Traceback (most recent call last):
        2: from -:5:in `<main>'
        1: from -:5:in `new'
-:5:in `initialize': too short control escape: /[\H-\x{B0308D30}*[]

Comment 5 Mamoru TASAKA 2017-09-15 07:13:19 UTC
(In reply to Doran Moppert from comment #2)
> Note also the second upstream patch:
> https://github.com/kkos/oniguruma/commit/
> ddbf55698b5f7ffdfa737b0b8e0079af1fdd7cb1

On Fedora, I submitted oniguruma-6.1.3-3.fc25 .
oniguruma on F-26 and above already contains this fix.
(F-24 is EOL)

Comment 7 errata-xmlrpc 2018-05-03 05:07:02 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