Skip to content

Fix format string vulnerability in FFmpeg MP4 demuxer diagnostics - #2315

Open
GuTS805 wants to merge 2 commits into
CCExtractor:masterfrom
GuTS805:fix-mp4-format-string-2312
Open

Fix format string vulnerability in FFmpeg MP4 demuxer diagnostics#2315
GuTS805 wants to merge 2 commits into
CCExtractor:masterfrom
GuTS805:fix-mp4-format-string-2312

Conversation

@GuTS805

@GuTS805 GuTS805 commented Aug 11, 2026

Copy link
Copy Markdown

[FIX]

processmp4_rust() and dumpchapters_rust() (src/rust/src/demuxer/mp4.rs) build diagnostic strings from untrusted input (e.g. the input filename) and pass them directly as the format-string argument to mprint(), which forwards to vfprintf(). Any % conversion specifier in that data is interpreted against nonexistent varargs — reproduced crash: a filename like %s%s%s%s%s%s%s%s.mp4 segfaults inside vfprintf (GDB backtrace in #2312).

This adds mprint_str(), which always calls mprint() with a literal "%s" format string and the message as its argument, and routes all 16 mprint() call sites in this file through it, so untrusted data can never be interpreted as a format string.

Fixes #2312

Note for reviewers: I see #2314 also addresses this issue with a similar approach (a dedicated mprint_arguments() module + unit test). Filing this since it's my own reported issue and I'd already built/verified a fix independently, but happy to defer to whichever approach maintainers prefer — feel free to close this one if #2314 is preferred.

In raising this pull request, I confirm the following (please check boxes):

Reason for this PR:

  • This PR fixes a bug that I have personally experienced or that a real user has reported and for which a sample exists.

Sanity check:

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist. (Note: Make FFmpeg MP4 diagnostics format-safe #2314 exists — flagged above transparently rather than hidden.)
  • If the PR adds new functionality, I've added it to the changelog. If it's just a bug fix, I have NOT added it to the changelog.
  • I am NOT adding new C code unless it's to fix an existing, reproducible bug.

Repro instructions:

  1. Build with the enable_mp4_ffmpeg feature / CMake WITH_FFMPEG=ON.
  2. Run: ccextractor '%s%s%s%s%s%s%s%s.mp4'
  3. Before fix: segfaults inside vfprintf (see GDB backtrace in issue Format string vulnerability (crash, CWE-134) in FFmpeg MP4 demuxer — filename passed directly as mprint() format string #2312).
  4. After fix: the filename is printed literally as data, no crash.

GuTS805 added 2 commits August 5, 2026 04:49
…ects

dvbsub_parse_object_segment() previously returned 0 (success) when
encountering a character-coded (coding_method == 1) DVB subtitle
object, silently dropping the caption content. Now returns -1 so
the caller (dvbsub_decode) correctly treats this as a failure.

Fixes CCExtractor#2303
processmp4_rust() and dumpchapters_rust() passed diagnostic strings
built from untrusted input (e.g. the input filename) directly as the
format-string argument to mprint(), which forwards to vfprintf(). Any
'%' conversion specifier in that data would be interpreted against
nonexistent varargs, causing a crash (reproduced: a filename like
'%s%s%s%s%s%s%s%s.mp4' segfaults inside vfprintf).

Added mprint_str(), which always calls mprint() with a literal "%s"
format string and the message as its argument, and routed all 16
mprint() call sites in this file through it so untrusted data can
never be interpreted as a format string.

Fixes CCExtractor#2312
@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit c328108...:
Report Name Tests Passed
Broken 9/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 2/2
General 22/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 69/86
Teletext 0/21
WTV 12/13
XDS 31/34

Your PR breaks these cases:

NOTE: The following tests have been failing on the master branch as well as the PR:


It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you).

Check the result page for more info.

@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 6077cf5...:
Report Name Tests Passed
Broken 9/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 2/2
General 22/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 69/86
Teletext 0/21
WTV 12/13
XDS 31/34

Your PR breaks these cases:

NOTE: The following tests have been failing on the master branch as well as the PR:


It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you).

Check the result page for more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Format string vulnerability (crash, CWE-134) in FFmpeg MP4 demuxer — filename passed directly as mprint() format string

2 participants