mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2026-01-23 23:21:06 +01:00
libavformat/mov.c: attacker-controlled count in mov_read_keys can trigger excessive allocations / OOM #229
Labels
No labels
bug
enhancement
help wanted
invalid
pull-request
question
upstream
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: starred/ffmpeg-rockchip#229
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @fa1c4 on GitHub (Dec 20, 2025).
Description
While fuzzing
ffmpeg-rockchip, I found thatlibavformat/mov.c→mov_read_keys()can be forced into excessive memory allocation due to insufficient bounding of the user-controlled key count (count) read from thekeysatom in MOV/MP4 metadata.The current check prevents integer overflow in the pointer-array allocation, but still permits very large
countvalues that cause multi-GB allocations (and then additional per-key allocations), leading to out-of-memory termination and a reliable denial-of-service when parsing a crafted file.Affected code
libavformat/mov.c→mov_read_keys()Relevant snippet (current behavior):
Impact
Root cause analysis
countis attacker-controlled (read from the file) and only checked for overflow safety, not for reasonable upper bounds relative to:~count * sizeof(pointer)can still be enormous (multi-GB) and cause OOM.key_sizeis used to allocatekey_size + 1bytes per entry without a strict bound against the remaining bytes in the atom/stream, amplifying memory pressure.Steps to reproduce
Reproduce with the attached fuzzer input (recommended)
Observed result (excerpt):
Expected behavior
Parsing should reject unreasonable
count/key_sizevalues early (returningAVERROR_INVALIDDATA) rather than attempting allocations that can exhaust memory.Actual behavior
The parser attempts to allocate extremely large buffers and the process is terminated due to OOM (reproducible under libFuzzer / constrained environments).
Environment
nyanmisaka/ffmpeg-rockchipoom-f528a3c32455549e702ad8b2c9f843770d63253b(attached)Suggested fix / mitigation
Any of the following (or a combination) would address the DoS vector:
countusing atom size / remaining bytes: ensurecountcannot exceed what can be represented by the remaining payload, given a minimum per-entry size.count(e.g., a maximum number of keys) to prevent unbounded allocations even if the atom claims huge counts.key_sizeagainst remaining bytes before allocating/reading, and reject entries that would exceed the atom boundary or an upper limit.I am happy to test a patch if you have a proposed change.
Attachments
https://github.com/user-attachments/assets/60c60f03-d187-40aa-b5ff-23a118ca028f
@nyanmisaka commented on GitHub (Dec 20, 2025):
For archival purposes, there are no plans to rebase the 6.x branch to the latest upstream commit.
Please use the latest 7.x and 8.x branch. https://github.com/nyanmisaka/ffmpeg-rockchip/branches