[pcre-dev] [Bug 2227] New: Heap overflow in pchars() pcretes…

Kezdőlap
Üzenet törlése
Szerző: admin
Dátum:  
Címzett: pcre-dev
Tárgy: [pcre-dev] [Bug 2227] New: Heap overflow in pchars() pcretest.c:204
https://bugs.exim.org/show_bug.cgi?id=2227

            Bug ID: 2227
           Summary: Heap overflow in pchars() pcretest.c:204
           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 1066
--> https://bugs.exim.org/attachment.cgi?id=1066&action=edit
Trigger

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

'(\w)'
0
0: 0
1: 0

//C
\D\C+
Callout 255: last capture = -1
=================================================================
==46060==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x62d000012400 at pc 0x000000416600 bp 0x7ffe797ba820 sp 0x7ffe797ba810
READ of size 1 at 0x62d000012400 thread T0
    #0 0x4165ff in pchars /works/f/pcre-8.41_test/pcretest.c:2045
    #1 0x417eca in callout /works/f/pcre-8.41_test/pcretest.c:2272
    #2 0x469822 in internal_dfa_exec
/works/f/pcre-8.41_test/pcre_dfa_exec.c:3078
    #3 0x47c051 in pcre_dfa_exec /works/f/pcre-8.41_test/pcre_dfa_exec.c:3616
    #4 0x40b16c in main /works/f/pcre-8.41_test/pcretest.c:5214
    #5 0x7fbf8a6c91c0 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x211c0)
    #6 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 0x7fbf8ab20961 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/pcretest.c:2045 pchars
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
==46060==ABORTING
_____________________________________________________________


Valgrind output :

PCRE version 8.41 2017-07-05

'(\w)'
0
0: 0
1: 0

//C
\D\C+
Callout 255: last capture = -1
==46210== Invalid read of size 1
==46210==    at 0x805798B: pchars (pcretest.c:2045)
==46210==    by 0x805798B: callout (pcretest.c:2272)
==46210==    by 0x8076BD0: internal_dfa_exec (pcre_dfa_exec.c:3078)
==46210==    by 0x8070F83: pcre_dfa_exec (pcre_dfa_exec.c:3616)
==46210==    by 0x8052357: main (pcretest.c:5214)
==46210==  Address 0x426fe70 is 0 bytes after a block of size 32,768 alloc'd
==46210==    at 0x402F17C: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==46210==    by 0x4031370: realloc (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==46210==    by 0x804E787: main (pcretest.c:4593)
==46210==


Cheers,

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