Bugzilla – Bug 922030
VUL-1: CVE-2015-2305: llvm: uses regular expressions (regex) library containing a heap overflow vulnerability
Last modified: 2016-12-12 11:01:07 UTC
+++ This bug was initially created as a clone of Bug #921950 +++
Guido Vranken reported that regular expressions (regex) originally written by Henry Spencer contains a heap overflow vulnerability.
CWE-122: Heap-based Buffer Overflow
The variable len that holds the length of a regular expression string is "enlarged to such an extent that, in the process of enlarging (multiplication and addition), causes the 32 bit register/variable to overflow." It may be possible for an attacker to use this overflow to change data in memory.
> int /* 0 success, otherwise REG_something */
> regcomp(preg, pattern, cflags)
> regex_t *preg;
> const char *pattern;
> int cflags;
> len = strlen((char *)pattern);
> p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */
> p->strip = (sop *)malloc(p->ssize * sizeof(sop));
32-bit systems are affected. It is highly unlikely that 64-bit operating systems would allow such an overflow. (Read: not impossible.)
The library is known to be contained in many different upstream source projects. The code may not be active or used on our platform, e.g. only be used as fallback code.
LLVM seems to contain affected code. Found in ./llvm/llvm-3.1.tar.bz2.contents/llvm/lib/Support/regcomp.c
bugbot adjusting priority
The attack scenario is as follows:
Excessively long (>700 MB) regular expression pattern by user parsed using regcomp.c
Please see attachment 627001 [details] to parent bug 921950 for an upstream patch taken from https://github.com/garyhouston/regex/commit/70bc2965604b6b8aaf260049e64c708dddf85334