Project: gpac (gpac/gpac), language: c++
Vulnerability instance: gpac.cve-2023-3291
Sanitizer: address

================= Bug Report (1/1) ==================
## Source: Huntr
## URL: https://huntr.dev/bounties/526954e6-8683-4697-bfa2-886c3204a1d5
## Description:
Description
Heap-buffer-overflow in MP4Box.
Version
MP4Box - GPAC version 2.3-DEV-revrelease
(c) 2000-2023 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io

Please cite our work in your research:
    GPAC Filters: https://doi.org/10.1145/3339825.3394929
    GPAC: https://doi.org/10.1145/1291233.1291452

GPAC Configuration: --enable-sanitizer
Features: GPAC_CONFIG_LINUX GPAC_64_BITS GPAC_HAS_IPV6 GPAC_HAS_SSL GPAC_HAS_SOCK_UN GPAC_MINIMAL_ODF GPAC_HAS_QJS GPAC_HAS_LINUX_DVB  GPAC_DISABLE_3D
Reproduce
complie and run
./configure --enable-sanitizer
make
Proof of Concept
./MP4Box -info ./poc.mp3
poc is here!
ASAN
information reported by sanitizer
==32961==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000001bb8 at pc 0x7fe8c604bcc3 bp 0x7ffc04e06160 sp 0x7ffc04e06150
WRITE of size 1 at 0x602000001bb8 thread T0
    #0 0x7fe8c604bcc2 in id3dmx_flush filters/reframe_mp3.c:274
    #1 0x7fe8c604de18 in mp3_dmx_flush_id3 filters/reframe_mp3.c:344
    #2 0x7fe8c604de18 in mp3_dmx_check_pid filters/reframe_mp3.c:417
    #3 0x7fe8c604de18 in mp3_dmx_process filters/reframe_mp3.c:657
    #4 0x7fe8c5bee15e in gf_filter_process_task filter_core/filter.c:2901
    #5 0x7fe8c5badd1a in gf_fs_thread_proc filter_core/filter_session.c:1962
    #6 0x7fe8c5bbb686 in gf_fs_run filter_core/filter_session.c:2264
    #7 0x7fe8c55ea3c6 in gf_media_import media_tools/media_import.c:1239
    #8 0x55a1aa648da1 in convert_file_info /home/functionmain/Desktop/gpac-master/applications/mp4box/fileimport.c:130
    #9 0x55a1aa6123a7 in mp4box_main /home/functionmain/Desktop/gpac-master/applications/mp4box/mp4box.c:6371
    #10 0x7fe8c2814082 in __libc_start_main ../csu/libc-start.c:308
    #11 0x55a1aa5eaebd in _start (/home/functionmain/Desktop/gpac-master/bin/gcc/MP4Box+0xa4ebd)

0x602000001bb8 is located 0 bytes to the right of 8-byte region [0x602000001bb0,0x602000001bb8)
allocated by thread T0 here:
    #0 0x7fe8c87e2c3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
    #1 0x7fe8c604b37a in id3dmx_flush filters/reframe_mp3.c:269
    #2 0x7fe8c604de18 in mp3_dmx_flush_id3 filters/reframe_mp3.c:344
    #3 0x7fe8c604de18 in mp3_dmx_check_pid filters/reframe_mp3.c:417
    #4 0x7fe8c604de18 in mp3_dmx_process filters/reframe_mp3.c:657
    #5 0x7fe8c5bee15e in gf_filter_process_task filter_core/filter.c:2901
    #6 0x7fe8c5badd1a in gf_fs_thread_proc filter_core/filter_session.c:1962
    #7 0x7fe8c5bbb686 in gf_fs_run filter_core/filter_session.c:2264
    #8 0x7fe8c55ea3c6 in gf_media_import media_tools/media_import.c:1239
    #9 0x55a1aa648da1 in convert_file_info /home/functionmain/Desktop/gpac-master/applications/mp4box/fileimport.c:130
    #10 0x55a1aa6123a7 in mp4box_main /home/functionmain/Desktop/gpac-master/applications/mp4box/mp4box.c:6371
    #11 0x7fe8c2814082 in __libc_start_main ../csu/libc-start.c:308

SUMMARY: AddressSanitizer: heap-buffer-overflow filters/reframe_mp3.c:274 in id3dmx_flush
Shadow bytes around the buggy address:
  0x0c047fff8320: fa fa fd fd fa fa 06 fa fa fa 00 01 fa fa 00 00
  0x0c047fff8330: fa fa 00 00 fa fa 00 00 fa fa 00 00 fa fa 00 00
  0x0c047fff8340: fa fa 00 00 fa fa 00 00 fa fa 00 00 fa fa 00 00
  0x0c047fff8350: fa fa 00 00 fa fa 00 00 fa fa 00 00 fa fa 00 00
  0x0c047fff8360: fa fa fd fa fa fa 00 00 fa fa 00 00 fa fa fd fa
=>0x0c047fff8370: fa fa 06 fa fa fa 00[fa]fa fa 05 fa fa fa 03 fa
  0x0c047fff8380: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8390: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff83a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff83b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff83c0: 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
==32961==ABORTING
Impact
This is capable of causing crashes.
References
poc
Impact
This is capable of causing crashes.

Relevant Links:
https://github.com/gpac/gpac
https://gitee.com/FUNctionMain/mypoc/raw/master/poc
https://gitee.com/FUNctionMain/mypoc/raw/master/poc
https://gitee.com/FUNctionMain/mypoc/raw/master/poc

Build script:
#!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
./configure --static-build --extra-cflags="${CFLAGS}" --extra-ldflags="${CFLAGS}"
make -j$(nproc)

Dockerfile:
FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y build-essential pkg-config libz-dev
RUN git clone https://github.com/gpac/gpac gpac
RUN git -C gpac checkout be234763f3513e662f5fa2b660e07e8c4bf67874
WORKDIR $SRC/gpac
COPY build.sh $SRC/

Additional files: