Menu

#304 Heap buffer overflow in PluginPCX.cpp:611

None
pending
5
2021-04-04
2020-02-13
freeKim
No

Heap buffer overflow in PluginPCX.cpp:611

Summary:

There is a heap buffer overflow in PluginPCX.cpp(line 611) while loading image with FreeImage_Load function。

Version Affected:

3.19.0 (r1828)

ASAN Details

==1193==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6130000001bd at pc 0x55df7e2433cc bp 0x7ffd0bd1ada0 sp 0x7ffd0bd1ad90
READ of size 1 at 0x6130000001bd thread T0
    #0 0x55df7e2433cb in Load Source/FreeImage/PluginPCX.cpp:611
    #1 0x55df7e19d47b in FreeImage_LoadFromHandle Source/FreeImage/Plugin.cpp:388
    #2 0x55df7e19d47b in FreeImage_LoadFromHandle Source/FreeImage/Plugin.cpp:380
    #3 0x55df7e19d952 in FreeImage_Load Source/FreeImage/Plugin.cpp:408
    #4 0x55df7e15812b in main /home/lab4/src/freeimage-svn/FreeImage/trunk/load-test.c:16
    #5 0x7fc59a21bb6a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26b6a)
    #6 0x55df7e168f69 in _start (/home/lab4/src/freeimage-svn/FreeImage/trunk/load-test+0x149f69)

0x6130000001bd is located 0 bytes to the right of 381-byte region [0x613000000040,0x6130000001bd)
allocated by thread T0 here:
    #0 0x7fc59a836448 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10c448)
    #1 0x55df7e23e239 in Load Source/FreeImage/PluginPCX.cpp:514
    #2 0x55df7e19d47b in FreeImage_LoadFromHandle Source/FreeImage/Plugin.cpp:388
    #3 0x55df7e19d47b in FreeImage_LoadFromHandle Source/FreeImage/Plugin.cpp:380
    #4 0x55df7e19d952 in FreeImage_Load Source/FreeImage/Plugin.cpp:408
    #5 0x55df7e15812b in main /home/lab4/src/freeimage-svn/FreeImage/trunk/load-test.c:16

SUMMARY: AddressSanitizer: heap-buffer-overflow Source/FreeImage/PluginPCX.cpp:611 in Load
Shadow bytes around the buggy address:
  0x0c267fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c267fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c267fff8000: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c267fff8010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c267fff8020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c267fff8030: 00 00 00 00 00 00 00[05]fa fa fa fa fa fa fa fa
  0x0c267fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff8080: 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
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  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
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==1193==ABORTING
Aborted

Reproduce

To reproduce it ,compile FreeImage with ASAN. Then compile and execute the test file in the attachment as follows:

Clang++ -g -fsanitize=address load-test.c -lfreeimage -L. -lm -o load-test
./load-test oob_read_PluginPCX_611

Credit

ADLab of Venustech

1 Attachments

Discussion

  • Hervé Drolon

    Hervé Drolon - 2021-04-04
    • status: open --> pending
    • assigned_to: Hervé Drolon
    • Group: -->
     

Log in to post a comment.

MongoDB Logo MongoDB