CVE-2026-66040
Executive Summary
CVE-2026-66040 is a heap out-of-bounds write vulnerability in FFmpeg's native PNG and APNG encoders, affecting FFmpeg through version 8.1.2. The flaw allows a remote attacker to corrupt heap memory by supplying a crafted PNG image containing a malicious eXIf chunk, potentially leading to process crash or arbitrary code execution. The vulnerability is triggered when the encoder processes an eXIf chunk with multiple IFD entries referencing the same large value payload, causing canonical serialization to exceed the allocation size and write tens of thousands of bytes past the buffer boundary.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Technical Analysis
The vulnerability resides in FFmpeg's native PNG and APNG encoding paths, specifically in the handling of eXIf chunks. When FFmpeg encodes a PNG image, it processes embedded Exif metadata and re-serializes it into a canonical form. The native PNG encoder includes an estimation function that calculates the buffer size required for the serialized Exif data before allocation.
The flaw occurs due to a mismatch between the estimated allocation size and the actual output size produced during canonical serialization. When a malicious PNG contains an eXIf chunk where multiple IFD (Image File Directory) entries reference the same large value payload, the canonical serialization process expands the output far beyond what the undersized allocation can accommodate.
This scenario creates a condition where the writing function natively used by the PNG encoder to emit chunk data writes tens of thousands of bytes past the allocated buffer boundary. The heap corruption is deterministic — meaning the same crafted input reliably produces the same memory corruption pattern on the same build — which makes it a viable target for exploitation rather than a probabilistic crash.
The attack surface is the library's decoding/encoding pipeline: a victim processes a crafted PNG file (e.g., via a media player, thumbnail generator, video converter, or web application that re-encodes uploaded images). Because FFmpeg is used pervasively across desktop applications, server-side media processing pipelines, video editing software, and browser plugins, the vulnerability is reachable in diverse environments.
The CWE classification is CWE-122 (Heap-based Buffer Overflow), consistent with the out-of-bounds write on the heap. The CVSS vector (AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H) indicates network exploitability with low attack complexity, no privileges required, and only user interaction needed to trigger the flaw, with high impact on confidentiality, integrity, and availability.
Exploitation Scenarios
Step 1 — Target Identification: An attacker identifies systems that process PNG files through FFmpeg. Likely targets include web applications with image upload/processing endpoints that invoke FFmpeg for thumbnail generation or format conversion, media servers (e.g., those transcoding user-submitted images), video editing applications, and content delivery pipelines.
Step 2 — Crafting the Malicious PNG: The attacker constructs a PNG file containing a valid IHDR, PLTE (if needed), and IDAT (image data) so the file passes basic validation. They then insert a crafted eXIf chunk containing a TIFF header, at least one IFD, and a large value payload referenced by multiple IFD entries. Each IFD entry is constructed to point to the same value payload offset, ensuring that canonical serialization will emit the payload multiple times — once per referencing entry — thereby expanding the serialized output beyond the encoder's estimate.
Step 3 — Weaponization: Prior to delivery, the attacker determines the heap layout target for their goal. Since the out-of-bounds write is deterministic in offset and size, the attacker can calculate which heap objects will be overwritten. Common targets include function pointers, heap metadata (which can be abused for a "house of force" style attack), or adjacent object data that controls program flow. For arbitrary code execution, the attacker can overwrite a function pointer or vtable entry that is invoked later in the encoding pipeline.
Step 4 — Delivery and Trigger: The attacker delivers the crafted PNG via any channel the target uses to receive images: email attachment, file upload form, phishing site, or direct URL. When the victim opens the file or the server-side pipeline processes it, FFmpeg decodes the PNG and begins re-encoding it. During re-encoding, the encoder processes the malicious eXIf chunk, triggers the undersized allocation, and then performs the out-of-bounds write during the serialization step.
Step 5 — Post-Exploitation: If the attacker achieves arbitrary code execution, they inherit the privileges of the process running FFmpeg. In server-side pipelines this often means the web application user or container service account, potentially enabling lateral movement, data exfiltration from the server's storage, or further compromise of connected services. In client-side scenarios, the attacker achieves code execution under the victim's user account, enabling full compromise of the user's session and local data.
Impact Assessment
The vulnerability carries a CVSS score of 8.8 categorized as High severity. The subscores break down as: Attack Vector Network, Attack Complexity Low, Privileges Required None, User Interaction Required, and Scope Unchanged, with High impacts on Confidentiality, Integrity, and Availability.
Business impact scenarios:
- Media Processing Platforms: Cloud or on-premises services that accept arbitrary image uploads (social platforms, CMS with image features, video hosting) are directly at risk. An attacker can submit a crafted PNG that, when processed, corrupts heap memory in the worker process, potentially crashing the service (availability impact) or achieving code execution (confidentiality and integrity impact).
- Desktop Applications: Software that relies on FFmpeg for image/PNG conversion (media players, converters, editors) exposes end users. A malicious attachment or web-downloaded image can compromise the end-user workstation.
- Supply Chain: FFmpeg is frequently bundled as a shared library. Organizations that redistribute FFmpeg in their products must track this fix carefully.
The blast radius is broad due to FFmpeg's ubiquity. Exploitation requires only user interaction (opening/processing a file), which lowers the barrier substantially. With no privilege requirements and low attack complexity, script-level automation of delivery is feasible.
While no public exploit or PoC is confirmed, the deterministic nature of the heap corruption and the straightforward trigger (a callback in a serialization routine) make this a candidate for weaponization by well-resourced threat actors. The EPSS score (0.00546, 42.7th percentile) suggests low but non-zero exploitation probability in the immediate term, indicating that exploitation is possible but not yet actively observed at scale.
Detection Guidance
Sigma Rule
title: Potential Exploitation of FFmpeg PNG eXIf Heap Overflow CVE-2026-66040
id: 5c1b2e6a-8f3d-4a7b-9c5d-2f6e8a1b3d4f
status: experimental
description: Detects anomalous PNG encoding or FFmpeg crash patterns indicative of CVE-2026-66040 exploitation.
logsource:
category: process_creation
product: linux
detection:
selection_ffmpeg:
Image|endswith:
- '/ffmpeg'
- '\ffmpeg.exe'
selection_extra_exif:
CommandLine|contains:
- '.png'
- '.apng'
selection_crash:
- EventID: 1010 # Windows Error Reporting
- Keywords: '*memory*corruption*'
condition: selection_ffmpeg and (selection_extra_exif or selection_crash)
level: medium
tags:
- attack.t1203
- cve.2026.66040
- cwe.122
YARA Rule
rule CVE_2026_66040_PNG_eXIf_Heap_Overflow {
meta:
author = "Valter Security"
description = "Detects crafted PNG files with malicious eXIf chunks referencing multiple IFD entries with shared value payloads (CVE-2026-66040)"
cve = "CVE-2026-66040"
date = "2025-11-12"
severity = "high"
strings:
$png_magic = { 89 50 4E 47 0D 0A 1A 0A }
$eXIf_chunk = { 65 58 49 66 } // "eXIf"
$tiff_header = { 49 49 2A 00 } // "II*\0" little-endian TIFF
// Common IFD entry structure: Tag(2) Type(2) Count(4) ValueOffset(4)
// Look for count > 16 indicating large value payload references
$large_count = { 10 00 00 00 } // 16 in 32-bit big-endian, a magnitude implying large value
condition:
$png_magic at 0 and $eXIf_chunk and $tiff_header and #large_count >= 2
}
Suricata IDS Rule
alert http any any -> any any (msg:"Potential CVE-2026-66040 PNG eXIf heap overflow attempt - oversized image upload"; flow:established,to_server; file.magic; fileext:"png"; file.size:>100000; detection_filter:track by_src, count 5, seconds 60; threshold:type limit, track by_src, count 100, seconds 60; classtype:attempted-user; sid:20266604001; rev:1;)
Elastic Detection
sequence with maxspan=5m
[ process where event.action == "exec" and process.name == "ffmpeg" or
process.args : ("*.png", "*.apng") ]
[ file where event.action in ("modify", "create") and
process.name == "ffmpeg" and
file.extension in ("png", "apng") ]
[ event.kind == "alert" and event.category == "process" and
process.name == "ffmpeg" and
event.code in ("abort", "segv", "bus") ]
Splunk SPL Query
index=main sourcetype=winregistry OR sourcetype=apache OR sourcetype=syslog
| where (process_name="ffmpeg*" OR CommandLine="*ffmpeg*")
| eventstats count as ffmpeg_events by host
| where ffmpeg_events < 100
| rex field=CommandLine "(?i)(?<file_ext>\.png|\.apng)\s*$"
| eval has_png = if(isnotnull(file_ext), 1, 0)
| where has_png=1
| rex field=_raw "(?i)(?<error_str>heap corruption|buffer overflow|segmentation fault|abort|out of memory)"
| eval has_error = if(isnotnull(error_str), 1, 0)
| where has_error=1 OR (event.code IN ("1010","1026","1000") AND host!="")
| table _time host process_name CommandLine error_str path
| sort - _time
Wazuh OSSEC Rule
<rule id="120404" level="10" frequency="2" timeframe="300">
<if_matched_sid>120400</if_matched_sid>
<field name="proc_name">whisper</field>
<match>ffmpeg</match>
<regex>\.png|\.apng</regex>
<description>Multiple FFmpeg crashes or errors processing PNG files - possible CVE-2026-66040 exploitation</description>
<group>exploit,png,heap_overflow,cve-2026-66040</group>
</rule>
<rule id="120405" level="12">
<if_sid>120404</if_sid>
<match>abort|segmentation|buffer overflow|heap corruption</match>
<description>FFmpeg heap corruption detected - CVE-2026-66040 exploitation likely</description>
<group>exploit,png,heap_overflow</group>
</rule>
Mitigation & Patch Guidance
Patch confidence: 2/4 (CLAIMED — single source claims patch, not independently confirmed)
Immediate Mitigations:
- Restrict user-supplied image processing: if your application accepts arbitrary PNG uploads that are then re-encoded through FFmpeg, disable the native PNG encoder and force a different codec path (e.g., convert PNG inputs to an intermediate format like TIFF or BMP using a hardened decoder before re-encoding).
- Run all FFmpeg processing in a sandboxed environment with minimal privileges — containerize media processing workers and limit their filesystem, network, and process access.
- Apply inter-process memory isolation: use a dedicated worker process per image encoding job so a crash or corruption does not affect the main application state.
- For desktop users, avoid opening PNG files from untrusted sources in applications that re-encode images (media players, editors, converters).
Patch/Upgrade Steps:
- Monitor the FFmpeg project for the commit
b506fafand upgrade to a release containing that commit. If your distribution uses FFmpeg 8.1.x, upgrade to the first patched snapshot (check the official FFmpeg git repository and release announcements). - For source builds: checkout the FFmpeg repository and apply the commit manually if it is not yet merged into a tagged release.
- For package-based systems: if a patched version is not yet available from your distribution, build FFmpeg from the latest git snapshot containing the fix.
- Rebuild any application binaries or libraries that statically link FFmpeg to ensure the patched code is included.
- Monitor the FFmpeg project for the commit
Long-Term Hardening:
- Adopt memory-safe languages or hardened allocators (e.g., jemalloc, mimalloc) in media-processing environments where practical.
- Enable ASLR, stack canaries, and RELRO in build configurations to raise the bar for memory corruption exploitation.
- Instrument CI pipelines with fuzzing targeted at media parsing and encoding paths (e.g., libFuzzer, AFL++ with FFmpeg harnesses) to catch similar allocation-size estimation bugs.
- Subscribe to FFmpeg security advisories and maintain a patch-window SLA (e.g., apply security fixes within 7 days for media-processing services).
References
- NVD Entry for CVE-2026-66040 — https://nvd.nist.gov/vuln/detail/CVE-2026-66040
- FFmpeg Official Git Repository — https://git.ffmpeg.org/gitweb/ffmpeg.git
- FFmpeg Release Announcements — https://ffmpeg.org/download.html
- Certified Secure Software Lifecycle (CSSL) CWE-122 Reference — https://cwe.mitre.org/data/definitions/122.html
- FIRST EPSS Score Lookup — https://www.first.org/epss/
No known threat actor campaigns or confirmed exploit-in-the-wild evidence were reported at the time of this analysis (CISA KEV status: NO).
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.