# Version
```
$ ./MP4Box -version
MP4Box - GPAC version 2.3-DEV-rev566-g50c2ab06f-master
```

# Platform
```
$ uname -a
Linux user-GE40-2PC-Dragon-Eyes 6.2.0-33-generic #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep  7 10:33:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
```

# Asan
```
/home/user/vul/MP4Box_crash/id000105sig06src005557time57542460execs543848ophavocrep8
[31m[Core] exp-golomb read failed, not enough bits in bitstream !
[0m[31m[HEVC] Error parsing NAL unit type 33
[0m[31m[HEVC] Error parsing Sequence Param Set
[0m[31m[BS] Attempt to overread bitstream
[0m[31m[Core] exp-golomb read failed, not enough bits in bitstream !
[0m[31m[HEVC] Wrong number of output layer sets in VPS 242, max 4 supported
[0m[31m[HEVC] Failed to parse VPS extensions
[0m[31m[Core] exp-golomb read failed, not enough bits in bitstream !
[0m[31m[HEVC] Error parsing NAL unit type 32
[0m[32m[Dasher] No template assigned, using $File$_dash$FS$$Number$
[0m[31m[HEVC] Wrong param set size 23573
[0m[31m[Core] exp-golomb read failed, not enough bits in bitstream !
[0m[31m[HEVC] Error parsing NAL unit type 33
[0m[31m[HEVC] Error parsing Sequence Param Set
[0m=================================================================
==835250==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6140000009f4 at pc 0x7fe74e25ad41 bp 0x7ffdbf9be150 sp 0x7ffdbf9be148
READ of size 1 at 0x6140000009f4 thread T0
    #0 0x7fe74e25ad40 in naludmx_process /home/user/fuzzing_gpac/gpac/src/filters/reframe_nalu.c:3269:23
    #1 0x7fe74ddafa33 in gf_filter_process_task /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:2971:7
    #2 0x7fe74dd7d47b in gf_fs_thread_proc /home/user/fuzzing_gpac/gpac/src/filter_core/filter_session.c:2105:3
    #3 0x7fe74dd7b5cf in gf_fs_run /home/user/fuzzing_gpac/gpac/src/filter_core/filter_session.c:2405:3
    #4 0x7fe74d62ac6a in gf_dasher_process /home/user/fuzzing_gpac/gpac/src/media_tools/dash_segmenter.c:1236:6
    #5 0x5601a8e0b6dc in do_dash /home/user/fuzzing_gpac/gpac/applications/mp4box/mp4box.c:4831:15
    #6 0x5601a8dfcb6e in mp4box_main /home/user/fuzzing_gpac/gpac/applications/mp4box/mp4box.c:6245:7
    #7 0x7fe74c629d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #8 0x7fe74c629e3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #9 0x5601a8d24dd4 in _start (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x82dd4) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)

0x6140000009f4 is located 0 bytes to the right of 436-byte region [0x614000000840,0x6140000009f4)
allocated by thread T0 here:
    #0 0x5601a8da8046 in __interceptor_realloc (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x106046) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
    #1 0x7fe74e24fbe4 in naludmx_process /home/user/fuzzing_gpac/gpac/src/filters/reframe_nalu.c:3122:21
    #2 0x7fe74ddafa33 in gf_filter_process_task /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:2971:7

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/user/fuzzing_gpac/gpac/src/filters/reframe_nalu.c:3269:23 in naludmx_process
Shadow bytes around the buggy address:
  0x0c287fff80e0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fff80f0: fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa
  0x0c287fff8100: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c287fff8110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c287fff8120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c287fff8130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00[04]fa
  0x0c287fff8140: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c287fff8150: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fff8160: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fff8170: fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa
  0x0c287fff8180: 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
==835250==ABORTING
```

# Reproduce
```
./MP4Box -dash 10000 poc
```
 
# POC File
https://github.com/gandalf4a/crash_report/blob/main/gpac/MP4Box/hbo_3269

# Credit
```
Gandalf4a
```
heap-buffer-overflow in /gpac/src/filters/reframe_nalu.c:3269:23 in naludmx_process
This is a GitHub Issue
repo:gpac
owner:gpac
Title : heap-buffer-overflow in /gpac/src/filters/reframe_nalu.c:3269:23 in naludmx_process
Issue date:

--- start body ---
# Version
```
$ ./MP4Box -version
MP4Box - GPAC version 2.3-DEV-rev566-g50c2ab06f-master
```

# Platform
```
$ uname -a
Linux user-GE40-2PC-Dragon-Eyes 6.2.0-33-generic #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep  7 10:33:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
```

# Asan
```
/home/user/vul/MP4Box_crash/id000105sig06src005557time57542460execs543848ophavocrep8
[31m[Core] exp-golomb read failed, not enough bits in bitstream !
[0m[31m[HEVC] Error parsing NAL unit type 33
[0m[31m[HEVC] Error parsing Sequence Param Set
[0m[31m[BS] Attempt to overread bitstream
[0m[31m[Core] exp-golomb read failed, not enough bits in bitstream !
[0m[31m[HEVC] Wrong number of output layer sets in VPS 242, max 4 supported
[0m[31m[HEVC] Failed to parse VPS extensions
[0m[31m[Core] exp-golomb read failed, not enough bits in bitstream !
[0m[31m[HEVC] Error parsing NAL unit type 32
[0m[32m[Dasher] No template assigned, using $File$_dash$FS$$Number$
[0m[31m[HEVC] Wrong param set size 23573
[0m[31m[Core] exp-golomb read failed, not enough bits in bitstream !
[0m[31m[HEVC] Error parsing NAL unit type 33
[0m[31m[HEVC] Error parsing Sequence Param Set
[0m=================================================================
==835250==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6140000009f4 at pc 0x7fe74e25ad41 bp 0x7ffdbf9be150 sp 0x7ffdbf9be148
READ of size 1 at 0x6140000009f4 thread T0
    #0 0x7fe74e25ad40 in naludmx_process /home/user/fuzzing_gpac/gpac/src/filters/reframe_nalu.c:3269:23
    #1 0x7fe74ddafa33 in gf_filter_process_task /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:2971:7
    #2 0x7fe74dd7d47b in gf_fs_thread_proc /home/user/fuzzing_gpac/gpac/src/filter_core/filter_session.c:2105:3
    #3 0x7fe74dd7b5cf in gf_fs_run /home/user/fuzzing_gpac/gpac/src/filter_core/filter_session.c:2405:3
    #4 0x7fe74d62ac6a in gf_dasher_process /home/user/fuzzing_gpac/gpac/src/media_tools/dash_segmenter.c:1236:6
    #5 0x5601a8e0b6dc in do_dash /home/user/fuzzing_gpac/gpac/applications/mp4box/mp4box.c:4831:15
    #6 0x5601a8dfcb6e in mp4box_main /home/user/fuzzing_gpac/gpac/applications/mp4box/mp4box.c:6245:7
    #7 0x7fe74c629d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #8 0x7fe74c629e3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #9 0x5601a8d24dd4 in _start (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x82dd4) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)

0x6140000009f4 is located 0 bytes to the right of 436-byte region [0x614000000840,0x6140000009f4)
allocated by thread T0 here:
    #0 0x5601a8da8046 in __interceptor_realloc (/home/user/fuzzing_gpac/gpac/bin/gcc/MP4Box+0x106046) (BuildId: 53333ca7bff59dd9a3d1b2821e7c5f3a9aac76b9)
    #1 0x7fe74e24fbe4 in naludmx_process /home/user/fuzzing_gpac/gpac/src/filters/reframe_nalu.c:3122:21
    #2 0x7fe74ddafa33 in gf_filter_process_task /home/user/fuzzing_gpac/gpac/src/filter_core/filter.c:2971:7

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/user/fuzzing_gpac/gpac/src/filters/reframe_nalu.c:3269:23 in naludmx_process
Shadow bytes around the buggy address:
  0x0c287fff80e0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fff80f0: fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa
  0x0c287fff8100: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c287fff8110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c287fff8120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c287fff8130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00[04]fa
  0x0c287fff8140: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c287fff8150: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fff8160: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fff8170: fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa
  0x0c287fff8180: 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
==835250==ABORTING
```

# Reproduce
```
./MP4Box -dash 10000 poc
```
 
# POC File
https://github.com/gandalf4a/crash_report/blob/main/gpac/MP4Box/hbo_3269

# Credit
```
Gandalf4a
```
--- end body ---

A heap buffer overflow vulnerability in the GPAC MP4Box application, specifically in the naludmx_process function located in reframe_nalu.c, can be exploited by providing a specially crafted input file. This vulnerability can lead to memory corruption and potentially allow an attacker to execute arbitrary code or cause a denial of service (application crash).