CVE-2026-66041 Overview
CVE-2026-66041 is a heap out-of-bounds write vulnerability [CWE-787] in FFmpeg versions 7.0 through 8.1.2. The flaw resides in the vf_quirc filter, which processes QR codes in video frames. An attacker can trigger heap corruption by supplying a crafted Presentation Graphics Stream (PGS) or SUP subtitle file containing mismatched frame dimensions. When the second subtitle presentation declares larger dimensions than the first, av_image_copy_plane() writes data beyond the initial allocation into the undersized libquirc grayscale image buffer. The result is heap corruption, a process crash, and the potential for arbitrary code execution. The issue is fixed in commit 4da9812.
Critical Impact
Remote attackers can corrupt heap memory and potentially execute arbitrary code by delivering a malicious subtitle file processed by an affected FFmpeg build.
Affected Products
- FFmpeg 7.0 through 8.1.2
- Applications embedding libavfilter with the vf_quirc filter enabled
- Downstream tools and media pipelines that process untrusted PGS/SUP subtitle streams via FFmpeg
Discovery Timeline
- 2026-07-24 - CVE-2026-66041 published to the National Vulnerability Database (NVD)
- 2026-07-29 - Last updated in NVD database
Technical Details for CVE-2026-66041
Vulnerability Analysis
The vulnerability exists in the vf_quirc video filter that scans decoded frames for QR codes using the libquirc library. FFmpeg allocates a grayscale image buffer sized to the dimensions of the first subtitle presentation it processes. Subsequent presentations reuse that same buffer without revalidating its capacity against the new frame dimensions.
When a subsequent presentation carries larger width or height values, the copy operation writes past the end of the allocated buffer. This corrupts adjacent heap metadata and data structures, giving an attacker influence over the layout of the process address space.
Root Cause
The root cause is a missing size validation between the allocated libquirc grayscale image buffer and the source frame dimensions on subsequent presentations. av_image_copy_plane() trusts the caller-supplied stride and height rather than clamping to the destination allocation. This mismatch between allocation size and copy length produces the out-of-bounds write.
Attack Vector
Exploitation requires an attacker to supply a crafted PGS or SUP subtitle file that the target processes with FFmpeg while the vf_quirc filter is active. The first presentation defines a small frame, forcing a small allocation. A second presentation declares larger dimensions, and the copy overruns the heap buffer. Delivery paths include media conversion services, streaming pipelines, and any web service that ingests user-supplied subtitle files. User interaction is limited to loading or processing the file.
See the VulnCheck Advisory on FFmpeg and the FFmpeg Commit Details for the corrective code.
Detection Methods for CVE-2026-66041
Indicators of Compromise
- Unexpected FFmpeg or ffmpeg-derived process crashes with SIGABRT, SIGSEGV, or glibc heap corruption messages such as malloc(): corrupted top size
- Core dumps referencing vf_quirc.c, libquirc, or av_image_copy_plane in the crash frame
- Ingestion of PGS or SUP subtitle files from untrusted sources immediately preceding a media worker crash
- Anomalous child processes spawned by media transcoding services after subtitle processing
Detection Strategies
- Inventory hosts and containers running FFmpeg 7.0 through 8.1.2 and flag any that expose transcoding to untrusted input
- Instrument transcoding services with AddressSanitizer or glibc heap protections in staging to surface out-of-bounds writes on suspicious inputs
- Alert on repeated crashes of FFmpeg worker processes handling subtitle streams within a short time window
Monitoring Recommendations
- Forward FFmpeg stderr, systemd journal entries, and container exit codes to a centralized logging pipeline
- Track process telemetry from media conversion hosts for abnormal memory usage, unexpected network connections, or shell spawns following subtitle ingestion
- Retain samples of subtitle files that trigger worker crashes for offline analysis
How to Mitigate CVE-2026-66041
Immediate Actions Required
- Upgrade FFmpeg to a build that includes commit 4da9812 or a vendor release that backports the fix
- Identify all embedded or bundled FFmpeg copies in first-party and third-party software and update them as well
- Restrict subtitle file uploads to trusted sources until patched builds are deployed
Patch Information
The fix is available in FFmpeg commit 4da9812e25894fb51d62a8875cfa8eb39b5e20f5, which adds proper size validation before invoking av_image_copy_plane() in the vf_quirc filter. Review the FFmpeg Pull Request and FFmpeg Commit Details for the full patch, then rebuild and redeploy affected binaries and container images.
Workarounds
- Disable the vf_quirc filter in FFmpeg build configurations by omitting --enable-libquirc where QR code processing is not required
- Strip or block PGS and SUP subtitle streams at ingest using a pre-processing step that rejects mismatched presentation dimensions
- Run FFmpeg workers under strict sandboxing (seccomp, AppArmor, or containers with no network egress) to limit the blast radius of a successful exploit
- Enforce input size limits and content-type validation for user-supplied media in upload pipelines
# Configuration example: rebuild FFmpeg without libquirc support
./configure --disable-filter=quirc --disable-libquirc
make -j$(nproc)
make install
# Verify the vf_quirc filter is no longer available
ffmpeg -filters | grep -i quirc
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

