Bug 1470107 (CVE-2017-11164)

Summary: CVE-2017-11164 pcre: OP_KETRMAX feature in the match function in pcre_exec.c
Product: [Other] Security Response Reporter: Andrej Nemec <anemec>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED WONTFIX QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: unspecifiedCC: adam.stokes, andrew, carnil, csutherl, databases-maint, erik-fedora, fedora-mingw, fedora, fidencio, gzaronik, hhorak, jclere, jdoyle, jgrulich, jorton, jshepherd, klember, lgao, lkundrak, marcandre.lureau, mbabacek, mclasen, mmuzila, mschorm, mturk, myarboro, pmyers, ppisar, pslavice, rcollet, rjones, rsvoboda, twalsh, walters, webstack-team, weli
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-07-12 12:10:36 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1470108, 1470109, 1470110, 1470111, 1470112, 1470113    
Bug Blocks:    

Description Andrej Nemec 2017-07-12 12:09:35 UTC
In PCRE 8.41, the OP_KETRMAX feature in the match function in pcre_exec.c allows stack exhaustion (uncontrolled recursion) when processing a crafted regular expression.

References:

http://seclists.org/oss-sec/2017/q3/111

Comment 1 Andrej Nemec 2017-07-12 12:09:56 UTC
Created glib2 tracking bugs for this issue:

Affects: fedora-all [bug 1470109]


Created mingw-glib2 tracking bugs for this issue:

Affects: epel-7 [bug 1470110]
Affects: fedora-all [bug 1470113]


Created mingw-pcre tracking bugs for this issue:

Affects: epel-7 [bug 1470112]
Affects: fedora-all [bug 1470108]


Created pcre tracking bugs for this issue:

Affects: fedora-all [bug 1470111]

Comment 2 Petr Pisar 2017-07-17 09:32:00 UTC
PCRE uses stack-based recursive algorithm for matching by default. The reproducer:

#include <pcreposix.h>
int main(void) {
    regex_t regtmp;

    if(regcomp(&regtmp,
                "\x28\x61\x2A\x5C\x56\x2A\x5C\x43\x2B\x29\x2A\x6F\xE5\xA2\x80",
                REG_UTF8) == 0) {  
        regmatch_t pmatch[1];
        regexec(&regtmp, "\x6C\x6F\xE5\xA2\x80\x2D ", 1, pmatch, 0);
        regfree(&regtmp);
    }
    return 0;
}

compiled with:

$ gcc $(pcre-config --cflags-posix --libs-posix) test.c -O0 -g

requires around 58000 KB of stack:

# su - test -c 'ulimit -s 57000 && /tmp/a.out'
Segmentation fault (core dumped)
# su - test -c 'ulimit -s 58000 && /tmp/a.out'

In my opinion this is not a bug.