Bento4
Bento4 copied to clipboard
Heap-Buffer-Overflow with ASAN in mp4info (AP4_HvccAtom)
Hi, developers of Bento4: I noticed that there are lots of heap-buffer-overflow error issues (#534 #629 #677 #707 ). I also meet this error in mp4info, so this problem have occured in mp4dump, mp4tag, mp42aac, mp4info . They are all from function AP4_HvccAtom::AP4_HvccAtom(unsigned int, unsigned char const)*, and the information is here:
=================================================================
==32854==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000000116 at pc 0x56043180306e bp 0x7ffe8a7deff0 sp 0x7ffe8a7defe8
READ of size 1 at 0x603000000116 thread T0
#0 0x56043180306d in AP4_HvccAtom::AP4_HvccAtom(unsigned int, unsigned char const*) (/workspace/test/Bento4/check_build/mp4info+0x18f06d) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#1 0x5604317fef90 in AP4_HvccAtom::Create(unsigned int, AP4_ByteStream&) (/workspace/test/Bento4/check_build/mp4info+0x18af90) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#2 0x5604317cc4e6 in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&, unsigned int, unsigned int, unsigned long long, AP4_Atom*&) (/workspace/test/Bento4/check_build/mp4info+0x1584e6) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#3 0x5604317cb6aa in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&, unsigned long long&, AP4_Atom*&) (/workspace/test/Bento4/check_build/mp4info+0x1576aa) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#4 0x5604317caed4 in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&, AP4_Atom*&) (/workspace/test/Bento4/check_build/mp4info+0x156ed4) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#5 0x5604317fa1bb in AP4_File::ParseStream(AP4_ByteStream&, AP4_AtomFactory&, bool) (/workspace/test/Bento4/check_build/mp4info+0x1861bb) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#6 0x5604317fa66a in AP4_File::AP4_File(AP4_ByteStream&, bool) (/workspace/test/Bento4/check_build/mp4info+0x18666a) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#7 0x5604317a2139 in main (/workspace/test/Bento4/check_build/mp4info+0x12e139) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#8 0x7fcdc2bc6d8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId: 89c3cb85f9e55046776471fed05ec441581d1969)
#9 0x7fcdc2bc6e3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f) (BuildId: 89c3cb85f9e55046776471fed05ec441581d1969)
#10 0x5604316e1b44 in _start (/workspace/test/Bento4/check_build/mp4info+0x6db44) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
0x603000000116 is located 0 bytes to the right of 22-byte region [0x603000000100,0x603000000116)
allocated by thread T0 here:
#0 0x56043179f86d in operator new[](unsigned long) (/workspace/test/Bento4/check_build/mp4info+0x12b86d) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#1 0x5604317f1d94 in AP4_DataBuffer::AP4_DataBuffer(unsigned int) (/workspace/test/Bento4/check_build/mp4info+0x17dd94) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#2 0x5604317cc4e6 in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&, unsigned int, unsigned int, unsigned long long, AP4_Atom*&) (/workspace/test/Bento4/check_build/mp4info+0x1584e6) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#3 0x5604317cb6aa in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&, unsigned long long&, AP4_Atom*&) (/workspace/test/Bento4/check_build/mp4info+0x1576aa) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#4 0x5604317caed4 in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&, AP4_Atom*&) (/workspace/test/Bento4/check_build/mp4info+0x156ed4) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#5 0x5604317fa1bb in AP4_File::ParseStream(AP4_ByteStream&, AP4_AtomFactory&, bool) (/workspace/test/Bento4/check_build/mp4info+0x1861bb) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#6 0x5604317fa66a in AP4_File::AP4_File(AP4_ByteStream&, bool) (/workspace/test/Bento4/check_build/mp4info+0x18666a) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#7 0x5604317a2139 in main (/workspace/test/Bento4/check_build/mp4info+0x12e139) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64)
#8 0x7fcdc2bc6d8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId: 89c3cb85f9e55046776471fed05ec441581d1969)
SUMMARY: AddressSanitizer: heap-buffer-overflow (/workspace/test/Bento4/check_build/mp4info+0x18f06d) (BuildId: 3c6e9c0c294b9dd4c01979220b14c84c2dc35b64) in AP4_HvccAtom::AP4_HvccAtom(unsigned int, unsigned char const*)
Shadow bytes around the buggy address:
0x0c067fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c067fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c067fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c067fff8000: fa fa 00 00 00 fa fa fa 00 00 00 fa fa fa 00 00
0x0c067fff8010: 00 fa fa fa 00 00 00 fa fa fa 00 00 00 fa fa fa
=>0x0c067fff8020: 00 00[06]fa fa fa 00 00 06 fa fa fa fa fa fa fa
0x0c067fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c067fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c067fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c067fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c067fff8070: 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
==32854==ABORTING
Crash input:
https://github.com/Yhcrown/fuzzing-crashes/blob/main/validated/mp4info/0
Verification steps:
git clone https://github.com/axiomatic-systems/Bento4
cd Bento4/
mkdir check_build && cd check_build
cmake ../ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="-fsanitize=address" -DCMAKE_CXX_FLAGS="-fsanitize=address" -DCMAKE_BUILD_TYPE=Release
make -j
./mp4info ./crash_input
enviroment: Ubuntu 22.04 LTS Linux lab-pro 4.15.0-147-generic gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0 Ubuntu clang version 14.0.6
Thanks & Best regards !