[pcre-dev] [Bug 2226] New: heap overflow in match src/pcre_…

Top Page
Delete this message
Author: admin
Date:  
To: pcre-dev
Subject: [pcre-dev] [Bug 2226] New: heap overflow in match src/pcre_exec.c:2311
https://bugs.exim.org/show_bug.cgi?id=2226

            Bug ID: 2226
           Summary: heap overflow in match src/pcre_exec.c:2311
           Product: PCRE
           Version: 8.41
          Hardware: x86
                OS: All
            Status: NEW
          Severity: bug
          Priority: medium
         Component: Code
          Assignee: ph10@???
          Reporter: simo.ghannam@???
                CC: pcre-dev@???


Created attachment 1065
--> https://bugs.exim.org/attachment.cgi?id=1065&action=edit
file triggering the bug

Hi,

I found this bug by fuzzing pcre 8.41
here is the output of ASAN compiled library
_____________________________________________________________
./pcretest reg.txt
PCRE version 8.41 2017-07-05

PCRE version 8.41 2017-07-05

/./<CRLF>
\P
=================================================================
==45618==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x62d000012400 at pc 0x0000004a8d4e bp 0x7ffc36043d00 sp 0x7ffc36043cf0
READ of size 1 at 0x62d000012400 thread T0
    #0 0x4a8d4d in match /works/f/pcre-8.41_test/pcre_exec.c:2311
    #1 0x4b284c in pcre_exec /works/f/pcre-8.41_test/pcre_exec.c:6936
    #2 0x40ca9f in main /works/f/pcre-8.41_test/pcretest.c:5227
    #3 0x7f89b4d151c0 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x211c0)
    #4 0x414919 in _start (/works/f/pcre-8.41_test/pcretest+0x414919)


0x62d000012400 is located 0 bytes to the right of 32768-byte region
[0x62d00000a400,0x62d000012400)
allocated by thread T0 here:
    #0 0x7f89b516c961 in realloc
(/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98961)
    #1 0x407dad in main /works/f/pcre-8.41_test/pcretest.c:4593


SUMMARY: AddressSanitizer: heap-buffer-overflow
/works/f/pcre-8.41_test/pcre_exec.c:2311 match
Shadow bytes around the buggy address:
  0x0c5a7fffa430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c5a7fffa440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c5a7fffa450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c5a7fffa460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c5a7fffa470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c5a7fffa480:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c5a7fffa490: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c5a7fffa4a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c5a7fffa4b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c5a7fffa4c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c5a7fffa4d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
==45618==ABORTING
_____________________________________________________________
Valgrind output :


PCRE version 8.41 2017-07-05

/./<CRLF>
\P
==45731== Invalid read of size 1
==45731==    at 0x8080623: match (pcre_exec.c:2311)
==45731==    by 0x807A578: pcre_exec (pcre_exec.c:6936)
==45731==    by 0x80524F0: main (pcretest.c:5227)
==45731==  Address 0x426fe68 is 0 bytes after a block of size 32,768 alloc'd
==45731==    at 0x402F17C: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==45731==    by 0x4031370: realloc (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==45731==    by 0x804E787: main (pcretest.c:4593)
==45731==


Cheers,

--
You are receiving this mail because:
You are on the CC list for the bug.