[security] compositor/mpeg4_geometry_2d.c:719 Invalid Pointer Dereference in PointSet2D_Draw

Open
#4,074 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
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c

Research direction

Reproduce with an ASAN build using the linked .xmt sample, then read compositor/mpeg4_geometry_2d.c:719 (PointSet2D_Draw) and its callers TraversePointSet2D (lines 747, 775), plus the drawable path in compositor/drawable.c (call_drawable_draw, drawable_finalize_sort_ex). Follow how the PointSet2D node's point and coordinate descriptors are parsed and stored, and find where malformed data leaves a pointer unchecked before drawing. Done when the sample no longer hits the SEGV and valid PointSet2D scenes still render.

Written by the indexing model from the issue text.

Description

compositor/mpeg4_geometry_2d.c:719 Invalid Pointer Dereference in PointSet2D_Draw

Description:

While drawing a crafted XMT scene with a PointSet2D node, TraversePointSet2D (compositor/mpeg4_geometry_2d.c:747) dispatches to PointSet2D_Draw (compositor/mpeg4_geometry_2d.c:719) via the drawable finalize path (call_drawable_draw, drawable_finalize_sort_ex). A corrupted point/coordinate descriptor causes PointSet2D_Draw to read through an invalid pointer derived from the malformed point data. AddressSanitizer reports SEGV on unknown address 0x00003f000000 (READ access).

To Reproduce

Steps to reproduce the behavior:

./MP4Box -add ./227_PointSet2D_Draw_compositor_mpeg4_geometry_2d_c_719.xmt -new /dev/null
Output:

asan-build:

==403843==ERROR: AddressSanitizer: SEGV on unknown address 0x00003f000000 (pc 0x7f57f5195ac5 bp 0x7b87f2dec4c0 sp 0x7fff54fbedb0 T0)
==403843==The signal is caused by a READ memory access.
    #0 0x7f57f5195ac5 in PointSet2D_Draw compositor/mpeg4_geometry_2d.c:719
    #1 0x7f57f5195ac5 in TraversePointSet2D compositor/mpeg4_geometry_2d.c:747
    #2 0x7f57f487a384 in gf_node_traverse scenegraph/base_scenegraph.c:1164
    #3 0x7f57f514ace8 in call_drawable_draw compositor/drawable.c:48
    #4 0x7f57f5153373 in drawable_finalize_end compositor/drawable.c:887
    #5 0x7f57f5153373 in drawable_finalize_sort_ex compositor/drawable.c:987
    #6 0x7f57f5195608 in TraversePointSet2D compositor/mpeg4_geometry_2d.c:775
    #7 0x7f57f487a384 in gf_node_traverse scenegraph/base_scenegraph.c:1164
    #8 0x7f57f5194696 in TraverseShape compositor/mpeg4_geometry_2d.c:129
    #9 0x7f57f5194696 in TraverseShape compositor/mpeg4_geometry_2d.c:59
    #10 0x7f57f487a384 in gf_node_traverse scenegraph/base_scenegraph.c:1164
    #11 0x7f57f51a9be3 in group_2d_traverse compositor/mpeg4_grouping.c:170
    #12 0x7f57f487a384 in gf_node_traverse scenegraph/base_scenegraph.c:1164
    #13 0x7f57f523abf4 in visual_2d_draw_frame compositor/visual_manager_2d.c:891
    #14 0x7f57f5118b90 in gf_sc_draw_scene compositor/compositor.c:2469
    #15 0x7f57f5124d04 in gf_sc_render_frame compositor/compositor.c:2966
    #16 0x7f57f512a97b in gf_sc_draw_frame compositor/compositor.c:345
    #17 0x7f57f54daaba in compose_process filters/compose.c:111
    #18 0x7f57f5476169 in gf_filter_process_task filter_core/filter.c:3257
    #19 0x7f57f5446f03 in gf_fs_thread_proc filter_core/filter_session.c:2420
    #20 0x7f57f544bf7c in gf_fs_run filter_core/filter_session.c:2728
    #21 0x7f57f4ec64fb in gf_media_import media_tools/media_import.c:1639
    #22 0x563f8e9bfefd in import_file /run/media/user/8ed8205b-4114-4c2a-b2d0-e2ad6640262d/gpac/runtime/gpac_asan/applications/mp4box/fileimport.c:1733
    #23 0x563f8e97ab5c in do_add_cat /run/media/user/8ed8205b-4114-4c2a-b2d0-e2ad6640262d/gpac/runtime/gpac_asan/applications/mp4box/mp4box.c:4679
    #24 0x563f8e97d23b in mp4box_main /run/media/user/8ed8205b-4114-4c2a-b2d0-e2ad6640262d/gpac/runtime/gpac_asan/applications/mp4box/mp4box.c:6447
    #25 0x7f57f4233fb9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:59
    #26 0x7f57f42340d6 in __libc_start_main_impl ../csu/libc-start.c:360
    #27 0x563f8e95b0c0 in _start (/run/media/user/8ed8205b-4114-4c2a-b2d0-e2ad6640262d/gpac/runtime/gpac_asan/bin/gcc/MP4Box+0x4e0c0) (BuildId: d055c5484f27068a8903997f49222289a37b0af7)

==403843==Register values:
rax = 0x0000000000000003  rbx = 0x0000000000000000  rcx = 0x000000003f000004  rdx = 0x0000000000000000  
rdi = 0x000000003f000000  rsi = 0x00007b97f2de1a60  rbp = 0x00007b87f2dec4c0  rsp = 0x00007fff54fbedb0  
 r8 = 0x00007b87f2dec4d0   r9 = 0x0000000000000000  r10 = 0x0000000000000040  r11 = 0x00007bb7f2de73a0  
r12 = 0x00007cd7f2de0c80  r13 = 0x00007c37f2de1700  r14 = 0x00007bb7f2de73a0  r15 = 0x00007b97f2de1a50  
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV compositor/mpeg4_geometry_2d.c:719 in PointSet2D_Draw
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):

227_PointSet2D_Draw_compositor_mpeg4_geometry_2d_c_719.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.