heap-buffer-overflow in function skipwhite in vim/vim

Valid

Reported on

Oct 12th 2022


Description

heap-buffer-overflow in function skipwhite at charset.c:1706:12

vim version

git log
commit 56564964e6d0956c29687e8a10cb94fe42f5c097 (HEAD -> master, tag: v9.0.0719, origin/master, origin/HEAD)

Proof of Concept

/home/mist/fuzz/vim/vim/src/vim -u NONE -X -Z -e -s -S poc1 -c :qa!                         
==535898==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000006219 at pc 0x000000e9ea05 bp 0x7fff509ca140 sp 0x7fff509ca138
READ of size 1 at 0x602000006219 thread T0
    #0 0xe9ea04 in skipwhite /home/mist/fuzz/vim/vim/src/charset.c:1706:12
    #1 0xd2804a in compile_def_function /home/mist/fuzz/vim/vim/src/vim9compile.c:3457:9
    #2 0xcf6212 in ex_defcompile /home/mist/fuzz/vim/vim/src/userfunc.c:5220:13
    #3 0x6c165e in do_one_cmd /home/mist/fuzz/vim/vim/src/ex_docmd.c:2578:2
    #4 0x6c165e in do_cmdline /home/mist/fuzz/vim/vim/src/ex_docmd.c:990:17
    #5 0xafa767 in do_source_ext /home/mist/fuzz/vim/vim/src/scriptfile.c:1667:5
    #6 0xaf840e in do_source /home/mist/fuzz/vim/vim/src/scriptfile.c:1811:12
    #7 0xaf840e in cmd_source /home/mist/fuzz/vim/vim/src/scriptfile.c:1163:14
    #8 0x6c165e in do_one_cmd /home/mist/fuzz/vim/vim/src/ex_docmd.c:2578:2
    #9 0x6c165e in do_cmdline /home/mist/fuzz/vim/vim/src/ex_docmd.c:990:17
    #10 0xeb29bc in exe_commands /home/mist/fuzz/vim/vim/src/main.c:3135:2
    #11 0xeb29bc in vim_main2 /home/mist/fuzz/vim/vim/src/main.c:781:2
    #12 0xeafd2c in main /home/mist/fuzz/vim/vim/src/main.c:432:12
    #13 0x7fdde2977082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
    #14 0x41f1ed in _start (/home/mist/fuzz/vim/vim/src/vim+0x41f1ed)

0x602000006219 is located 0 bytes to the right of 9-byte region [0x602000006210,0x602000006219)
allocated by thread T0 here:
    #0 0x49a44d in malloc (/home/mist/fuzz/vim/vim/src/vim+0x49a44d)
    #1 0x4cb988 in lalloc /home/mist/fuzz/vim/vim/src/alloc.c:246:11

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/mist/fuzz/vim/vim/src/charset.c:1706:12 in skipwhite
Shadow bytes around the buggy address:
  0x0c047fff8bf0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff8c00: fa fa fd fa fa fa 00 00 fa fa 00 00 fa fa 05 fa
  0x0c047fff8c10: fa fa 00 fa fa fa fd fa fa fa fd fa fa fa 05 fa
  0x0c047fff8c20: fa fa 05 fa fa fa 00 01 fa fa 00 01 fa fa 02 fa
  0x0c047fff8c30: fa fa fd fa fa fa 02 fa fa fa 05 fa fa fa 05 fa
=>0x0c047fff8c40: fa fa 00[01]fa fa 03 fa fa fa fa fa fa fa fa fa
  0x0c047fff8c50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8c60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8c70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8c80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8c90: 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
==535898==ABORTING

poc1 download from url: https://drive.google.com/file/d/1iMaBNj1r8sikBe-xfUoSXrCFUz5qpUwC/view?usp=sharing

Impact

This vulnerability is capable of crashing software, modify memory, and possible remote execution.

We are processing your report and will contact the vim team within 24 hours. 2 months ago
mist1987 modified the report
2 months ago
mist1987 modified the report
2 months ago
mist1987 modified the report
2 months ago
We have contacted a member of the vim team and are waiting to hear back 2 months ago
Bram Moolenaar validated this vulnerability 2 months ago

I can reproduce it. It still reproduces when removing a few lines from the POC.

mist1987 has been awarded the disclosure bounty
The fix bounty is now up for grabs
The researcher's credibility has increased: +7
Bram Moolenaar
2 months ago

Maintainer


Fixed with patch 9.0.0742

Bram Moolenaar marked this as fixed in 9.0.0742 with commit 3558af 2 months ago
Bram Moolenaar has been awarded the fix bounty
This vulnerability will not receive a CVE
Pavlos published this vulnerability 3 days ago
to join this conversation