Skip to content

src/mp4property.h:420 Integer Underflow and Out-of-bounds Read in MP4BytesProperty::GetValueStringAlloc #91

Description

@sigdevel

src/mp4property.h:420 Integer Underflow and Out-of-bounds Read in MP4BytesProperty::GetValueStringAlloc

Description:

When processing a specially crafted MP4 file containing malformed iTunes metadata atoms, mp4info crashes in mp4v2::impl::MP4BytesProperty::GetValueStringAlloc(). The crash occurs while parsing the ITMF metadata item moov.udta.meta.ilst.----.mean. A malformed atom size appears to cause an integer underflow while calculating the value size. As a result, the value size is interpreted as 0xFFFFFFFD bytes and is later passed directly to memcpy() without proper validation.

To Reproduce

Steps to reproduce the behavior:

./mp4info src_mp4property_h_420

Output:

asan-build:

show full -click to expand
=================================================================
==136757==ERROR: AddressSanitizer: unknown-crash on address 0x0000fffffffd at pc 0x7f99cc322094 bp 0x7ffd1a46ebb0 sp 0x7ffd1a46e370
READ of size 4294967293 at 0x0000fffffffd thread T0                                                                                                        
    #0 0x7f99cc322093 in memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:117
    #1 0x56321dd8d8b1 in mp4v2::impl::MP4BytesProperty::GetValueStringAlloc(unsigned int) src/mp4property.h:420
    #2 0x56321dd873e9 in __itemAtomToModel src/itmf/generic.cpp:168
    #3 0x56321dd87b43 in mp4v2::impl::itmf::genericGetItems(mp4v2::impl::MP4File&) src/itmf/generic.cpp:308
    #4 0x56321dd80ed4 in mp4v2::impl::itmf::Tags::c_fetch(MP4Tags_s*&, void*) src/itmf/Tags.cpp:72
    #5 0x56321dd721f0 in MP4TagsFetch src/cmeta.cpp:133
    #6 0x56321dd69be7 in main util/mp4info.cpp:90
    #7 0x7f99cbc33f74 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #8 0x7f99cbc34026 in __libc_start_main_impl ../csu/libc-start.c:360
    #9 0x56321dd678e0 in _start (/run/media/user/81c71df6-ca99-4d27-a7b6-55107e347080/mp4v2/runtime/sub/mp4v2/mp4info_asan+0x638e0) (BuildId: b2233bfe65c7ff1709d4cbbd7012f55656916e28)

Address 0x0000fffffffd is located in the shadow gap area.
SUMMARY: AddressSanitizer: unknown-crash src/mp4property.h:420 in mp4v2::impl::MP4BytesProperty::GetValueStringAlloc(unsigned int)
==136757==ABORTING

Environment

OS: tested at 6.12.25-1kali1 (2025-04-30) x86_64 GNU/Linux ;
Compiler version: Clang 21.1.8 ;
Build-opts:  -fsanitize=address,undefined -g -O1 ;
CPU type: x86_64 ;
mp4v2 - commit hash b7cdf09167124136d7b6bc9f7aa5ebdc95ed5d61 ;
MP4v2 version - 2.0.0 ;

Additional context

link to the sample (github-url):

src_mp4property_h_420

Screenshots

screen

screen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions