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

Heap buffer overflow in csv.h:668 #67

Closed
fCorleone opened this issue Jul 6, 2018 · 2 comments
Closed

Heap buffer overflow in csv.h:668 #67

fCorleone opened this issue Jul 6, 2018 · 2 comments

Comments

@fCorleone
Copy link

fCorleone commented Jul 6, 2018

Heap buffer overflow occurred
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

=================================================================
==9445==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7ffff06ff7ff at pc 0x000000412fd4 bp 0x7fffffffd710 sp 0x7fffffffd700
READ of size 1 at 0x7ffff06ff7ff thread T0
    #0 0x412fd3 in io::trim_chars<(char)32, (char)9>::trim(char*&, char*&) /home/mfc_fuzz/cpp-csv-parser/csv.h:688
    #1 0x412fd3 in void io::detail::parse_header_line<3u, io::trim_chars<(char)32, (char)9>, io::no_quote_escape<(char)44> >(char*, std::vector<int, std::allocator<int> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, unsigned int) /home/mfc_fuzz/cpp-csv-parser/csv.h:884
    #2 0x414261 in void io::CSVReader<3u, io::trim_chars<(char)32, (char)9>, io::no_quote_escape<(char)44>, io::throw_on_overflow, io::no_comment>::read_header<char const*, char const*, char const*>(unsigned int, char const*, char const*, char const*) /home/mfc_fuzz/cpp-csv-parser/csv.h:1146
    #3 0x4027f7 in main /home/mfc_fuzz/cpp-csv-parser/main.c:7
    #4 0x7ffff652882f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #5 0x405008 in _start (/home/mfc_fuzz/cpp-csv-parser/prog+0x405008)

0x7ffff06ff7ff is located 1 bytes to the left of 50331648-byte region [0x7ffff06ff800,0x7ffff36ff800)
allocated by thread T0 here:
    #0 0x7ffff6f036b2 in operator new[](unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x996b2)
    #1 0x40ea27 in io::LineReader::init(std::unique_ptr<io::ByteSourceBase, std::default_delete<io::ByteSourceBase> >) /home/mfc_fuzz/cpp-csv-parser/csv.h:346
    #2 0x40ea27 in io::LineReader::LineReader(char const*) /home/mfc_fuzz/cpp-csv-parser/csv.h:367
    #3 0x40ea27 in io::CSVReader<3u, io::trim_chars<(char)32, (char)9>, io::no_quote_escape<(char)44>, io::throw_on_overflow, io::no_comment>::CSVReader<char*&>(char*&) /home/mfc_fuzz/cpp-csv-parser/csv.h:1119

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/mfc_fuzz/cpp-csv-parser/csv.h:688 io::trim_chars<(char)32, (char)9>::trim(char*&, char*&)
Shadow bytes around the buggy address:
  0x10007e0d7ea0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x10007e0d7eb0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x10007e0d7ec0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x10007e0d7ed0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x10007e0d7ee0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x10007e0d7ef0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa[fa]
  0x10007e0d7f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007e0d7f10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007e0d7f20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007e0d7f30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007e0d7f40: 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
  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
==9445==ABORTING

The test driver and the input case is displayed at :
https://github.com/fCorleone/fuzz_programs/blob/master/fast-cpp-csv-parser/test-driver.c
https://github.com/fCorleone/fuzz_programs/blob/master/fast-cpp-csv-parser/inputcase1

@ben-strasser
Copy link
Owner

Thank you for reporting this bug.

I just pushed a fix. Can you please check, if the bug is also resolved on your end?

If you find further fuzzer bugs, please report them. Such bug reports are very useful.

@carnil
Copy link

carnil commented Jul 8, 2018

This issue was assigned CVE-2018-13421

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants