[security] compositor/mpeg4_geometry_2d.c:687 Heap Buffer Overflow in pointset2d_check_changes

Open
#4,073 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c

Research direction

Reproduce first: build with AddressSanitizer and run the given MP4Box -add ... -new /dev/null command on the linked .xmt sample. Read pointset2d_check_changes at compositor/mpeg4_geometry_2d.c:687 and its caller TraversePointSet2D at line 743, then compare the node's advertised point count with the coordinates buffer allocated in XCurve2D_Create (scenegraph/mpeg4_nodes.c:32059). Done when the count is validated against the allocation and the sample no longer trips ASAN.

Written by the indexing model from the issue text.

Description

compositor/mpeg4_geometry_2d.c:687 Heap Buffer Overflow in pointset2d_check_changes

Description:

While traversing a crafted XMT scene containing a PointSet2D node, the compositor reaches pointset2d_check_changes (compositor/mpeg4_geometry_2d.c:687) through TraversePointSet2D (compositor/mpeg4_geometry_2d.c:743) and gf_node_traverse. The node advertises a point count that is inconsistent with the size of the allocated coordinates buffer, so the change-detection loop reads past the end of the heap allocation. AddressSanitizer reports a heap-buffer-overflow at compositor/mpeg4_geometry_2d.c:687.

To Reproduce

Steps to reproduce the behavior:

./MP4Box -add ./226_pointset2d_check_changes_compositor_mpeg4_geometry_2d_c_687.xmt -new /dev/null
Output:

asan-build:

==403823==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7c058b9e31fc at pc 0x7fc58dd95d1a bp 0x7ffcc775e370 sp 0x7ffcc775e368
READ of size 4 at 0x7c058b9e31fc thread T0
    #0 0x7fc58dd95d19 in pointset2d_check_changes compositor/mpeg4_geometry_2d.c:687
    #1 0x7fc58dd95d19 in TraversePointSet2D compositor/mpeg4_geometry_2d.c:743
    #2 0x7fc58d47a384 in gf_node_traverse scenegraph/base_scenegraph.c:1164
    #3 0x7fc58dd94696 in TraverseShape compositor/mpeg4_geometry_2d.c:129
    #4 0x7fc58dd94696 in TraverseShape compositor/mpeg4_geometry_2d.c:59
    #5 0x7fc58d47a384 in gf_node_traverse scenegraph/base_scenegraph.c:1164
    #6 0x7fc58dda9be3 in group_2d_traverse compositor/mpeg4_grouping.c:170
    #7 0x7fc58d47a384 in gf_node_traverse scenegraph/base_scenegraph.c:1164
    #8 0x7fc58de3abf4 in visual_2d_draw_frame compositor/visual_manager_2d.c:891
    #9 0x7fc58dd18b90 in gf_sc_draw_scene compositor/compositor.c:2469
    #10 0x7fc58dd24d04 in gf_sc_render_frame compositor/compositor.c:2966
    #11 0x7fc58dd2a97b in gf_sc_draw_frame compositor/compositor.c:345
    #12 0x7fc58e0daaba in compose_process filters/compose.c:111
    #13 0x7fc58e076169 in gf_filter_process_task filter_core/filter.c:3257
    #14 0x7fc58e046f03 in gf_fs_thread_proc filter_core/filter_session.c:2420
    #15 0x7fc58e04bf7c in gf_fs_run filter_core/filter_session.c:2728
    #16 0x7fc58dac64fb in gf_media_import media_tools/media_import.c:1639
    #17 0x55647cd80efd in import_file /run/media/user/8ed8205b-4114-4c2a-b2d0-e2ad6640262d/gpac/runtime/gpac_asan/applications/mp4box/fileimport.c:1733
    #18 0x55647cd3bb5c in do_add_cat /run/media/user/8ed8205b-4114-4c2a-b2d0-e2ad6640262d/gpac/runtime/gpac_asan/applications/mp4box/mp4box.c:4679
    #19 0x55647cd3e23b in mp4box_main /run/media/user/8ed8205b-4114-4c2a-b2d0-e2ad6640262d/gpac/runtime/gpac_asan/applications/mp4box/mp4box.c:6447
    #20 0x7fc58ce33fb9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:59
    #21 0x7fc58ce340d6 in __libc_start_main_impl ../csu/libc-start.c:360
    #22 0x55647cd1c0c0 in _start (/run/media/user/8ed8205b-4114-4c2a-b2d0-e2ad6640262d/gpac/runtime/gpac_asan/bin/gcc/MP4Box+0x4e0c0) (BuildId: d055c5484f27068a8903997f49222289a37b0af7)

0x7c058b9e31fc is located 4 bytes after 40-byte region [0x7c058b9e31d0,0x7c058b9e31f8)
allocated by thread T0 here:
    #0 0x7fc58f12435f in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:67
    #1 0x7fc58d4efd9a in XCurve2D_Create scenegraph/mpeg4_nodes.c:32059
    #2 0x7fc58d4efd9a in gf_sg_mpeg4_node_new scenegraph/mpeg4_nodes.c:37044

SUMMARY: AddressSanitizer: heap-buffer-overflow compositor/mpeg4_geometry_2d.c:687 in pointset2d_check_changes
Environment
OS: tested at 7.1.5+kali-amd64 x86_64 GNU/Linux ;
Compiler version: GCC 15.3.0-2 ;
CPU type: x86_64 ;
MP4Box - GPAC commit hash 425ef34eecf4583cf1163baca1df772e91a0ce35 ;
MP4Box - GPAC version 26.08-DEV-rev397-g425ef34ee-master ;
Additional context

link to the sample (github-url):

226_pointset2d_check_changes_compositor_mpeg4_geometry_2d_c_687.xmt

Screenshots

screen

screen

Dominant language
C
Stars
3.3k
Forks
601
Avg merge
3d 17h
Merged PRs (30d)
22

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from gpac/gpac

All issues in gpac/gpac

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.