Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddressSanitizer: heap-buffer-overflow in pspdf_prepare_page(int) ps-pdf.cxx:1440:19 #412

Closed
chibataiki opened this issue Jan 26, 2021 · 3 comments
Assignees
Labels
bug Something isn't working priority-high
Milestone

Comments

@chibataiki
Copy link

chibataiki commented Jan 26, 2021

Hello, While fuzzing htmldoc , I found a heap-buffer-overflow in the pspdf_prepare_page() ,in ps-pdf.cxx:1440:19

  • test platform
    htmldoc Version 1.9.12 git [master 6898d0a]
    OS :Ubuntu 20.04.1 LTS x86_64
    kernel: 5.4.0-53-generic
    compiler: clang version 10.0.0-4ubuntu1

reproduced:

htmldoc -f demo.pdf   poc1.html

poc(zipped for update): poc1.zip

=================================================================
==38053==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x621000002784 at pc 0x00000055eaf5 bp 0x7ffc477b4a50 sp 0x7ffc477b4a48
READ of size 4 at 0x621000002784 thread T0
    #0 0x55eaf4 in pspdf_prepare_page(int) /home/htmldoc_sani/htmldoc/ps-pdf.cxx:1440:19
    #1 0x54fa89 in pspdf_export /home/htmldoc_sani/htmldoc/ps-pdf.cxx:820:7
    #2 0x53c845 in main /home/htmldoc_sani/htmldoc/htmldoc.cxx:1291:3
    #3 0x7fab7bf310b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
    #4 0x41f8bd in _start (/home/htmldoc_sani/htmldoc/htmldoc+0x41f8bd)

0x621000002784 is located 644 bytes to the right of 4096-byte region [0x621000001500,0x621000002500)
freed by thread T0 here:
    #0 0x4ee210 in free /home/work/libfuzzer-workshop/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:124
    #1 0x7fab7bf9eff4 in _IO_setb /build/glibc-eX1tMB/glibc-2.31/libio/genops.c:331:5

previously allocated by thread T0 here:
    #0 0x4ee5df in __interceptor_malloc /home/work/libfuzzer-workshop/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:146
    #1 0x7fab7bf8ee83 in _IO_file_doallocate /build/glibc-eX1tMB/glibc-2.31/libio/filedoalloc.c:101:7

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/htmldoc_sani/htmldoc/ps-pdf.cxx:1440:19 in pspdf_prepare_page(int)
Shadow bytes around the buggy address:
  0x0c427fff84a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c427fff84b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c427fff84c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c427fff84d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c427fff84e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c427fff84f0:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c427fff8500: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c427fff8510: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c427fff8520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c427fff8530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c427fff8540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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
==38053==ABORTING

reporter: chiba of topsec alphalab

@chibataiki chibataiki changed the title AddressSanitizer: heap-buffer-overflow AddressSanitizer: heap-buffer-overflow in the pspdf_prepare_page function Jan 26, 2021
@chibataiki chibataiki changed the title AddressSanitizer: heap-buffer-overflow in the pspdf_prepare_page function AddressSanitizer: heap-buffer-overflow in pspdf_prepare_page(int) ps-pdf.cxx:1440:19 Jan 26, 2021
@michaelrsweet michaelrsweet self-assigned this Jan 26, 2021
@michaelrsweet michaelrsweet added bug Something isn't working priority-high labels Jan 26, 2021
@michaelrsweet michaelrsweet added this to the Stable milestone Jan 26, 2021
@michaelrsweet
Copy link
Owner

Confirmed, investigating...

@michaelrsweet
Copy link
Owner

Fixed by the changes for #414.

@chibataiki
Copy link
Author

CVE-2021-26252 assigned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-high
Projects
None yet
Development

No branches or pull requests

2 participants