# CVE-2026-66040: FFmpeg heap out-of-bounds write in PNG and APNG encoders

Source: https://junglewise.ai/threats/cve-2026-66040-ffmpeg-heap-out-of-bounds-write-in-png-and-apng-encoders  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-07-24. Updated: 2026-07-24  
License: CC BY 4.0 with a link back

CVE-2026-66040 · Severity: high · CVSS 8.8 · Published 2026-07-24

FFmpeg, a widely used multimedia framework for processing video and images, contains a vulnerability in how it handles certain image metadata. By providing a specially crafted PNG or APNG image, an attacker could cause the software to crash or potentially execute unauthorized commands. This could lead to service disruptions or the theft of sensitive data in applications that use FFmpeg to process user-uploaded images.

Technologies: [Ffmpeg](https://junglewise.ai/threats/technologies/ffmpeg). Vendors: [Ffmpeg](https://junglewise.ai/threats/vendors/ffmpeg).

## Quick answers

**Is CVE-2026-66040 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-66040 being exploited in the wild.

**How severe is CVE-2026-66040?** High severity, with a CVSS score of 8.8, published 24 July 2026.

**Which products and versions are affected?** Ffmpeg through 8.1.2.

**Is there a fix for CVE-2026-66040?** A patch was published on 2026-07-12: Fix committed to FFmpeg master branch Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-66040 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-66040?** Check whether you run Ffmpeg at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## Technical details

A heap-based buffer overflow (CWE-122) exists in the FFmpeg native PNG and APNG encoders. The vulnerability is rooted in the `add_exif_profile_size()` function, which underestimates the required buffer size for eXIf metadata. An attacker can craft a PNG with an eXIf chunk where multiple Image File Directory (IFD) entries reference the same large payload. During canonical serialization, these references are expanded, causing `png_write_chunk()` to write significantly past the allocated buffer. This results in deterministic heap corruption. The issue is fixed in commit b506faf by parsing the IFD to calculate the actual required size before allocation.

## Affected products

- FFmpeg FFmpeg through 8.1.2

## Timeline

- 2026-07-12: patched: Fix committed to FFmpeg master branch
- 2026-07-24: disclosed: CVE-2026-66040 published

## References

- [https://code.ffmpeg.org/FFmpeg/FFmpeg/commit/b506fafec9a19fcbc2be5271875fd4a63d6615bc](https://code.ffmpeg.org/FFmpeg/FFmpeg/commit/b506fafec9a19fcbc2be5271875fd4a63d6615bc)
- [https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23786](https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23786)
- [https://www.vulncheck.com/advisories/ffmpeg-heap-out-of-bounds-write-via-png-apng-exif-encoder](https://www.vulncheck.com/advisories/ffmpeg-heap-out-of-bounds-write-via-png-apng-exif-encoder)

## Related threats

- [FFmpeg heap out-of-bounds read in v4l2_buffers](https://junglewise.ai/threats/cve-2026-125270-ffmpeg-through-9-0-2-contains-a-heap-out-of-bounds-read)
- [FFmpeg double free in H.264 SEI message handling](https://junglewise.ai/threats/cve-2026-125269-ffmpeg-through-9-0-2-contains-a-double-free-vulnerability-in)
- [FFmpeg heap out-of-bounds write in APAC decoder](https://junglewise.ai/threats/cve-2026-125267-ffmpeg-before-8-1-3-and-9-x-before-9-0-2-contains-a-heap-out-of)
- [FFmpeg use-after-free in NVIDIA codec decoding](https://junglewise.ai/threats/cve-2026-125265-ffmpeg-through-9-0-2-contains-a-use-after-free-vulnerability-in)
- [FFmpeg JPEG XL parser uncontrolled resource consumption](https://junglewise.ai/threats/cve-2026-125264-ffmpeg-through-9-0-2-contains-an-uncontrolled-resource)
