# Next.js heap buffer overflow in image optimization via malicious AVIF

Source: https://junglewise.ai/threats/next-js-heap-buffer-overflow-in-image-optimization-via-malicious-avif-90b951e0  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-09-08. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

Severity: critical · CVSS 9.5 · Published 2026-09-08

Next.js's image optimization feature uses the libheif library (via the sharp library) to process AVIF image files. A crafted malicious AVIF file can trigger a heap buffer overflow when processed, allowing an unauthenticated remote attacker to execute arbitrary code on the server. This affects any Next.js application that automatically optimizes images, enabling complete system compromise.

Technologies: [Vercel Next.js](https://junglewise.ai/threats/technologies/next-js). Vendors: [Vercel](https://junglewise.ai/threats/vendors/vercel).

## Quick answers

**Is This vulnerability exploited in the wild?** No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.

**How severe is This vulnerability?** Critical severity, with a CVSS score of 9.5, published 8 September 2026.

**Which products and versions are affected?** Vercel Next.js >=10.0.0, <15.5.24 or >=16.0.0, <16.3.3.

**Is there a fix for This vulnerability?** A patch was published on 2026-08-25: Patches released as Next.js 15.5.24 and 16.3.3 Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is This vulnerability attacked?** It is attacked over the network, in a web application.

**Am I affected?** Check whether you run Vercel Next.js 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

The vulnerability is a heap buffer overflow in libheif's scale_nearest_neighbor() function, triggered by a specially crafted AVIF file containing nested identity-derivation (iden) and auxiliary (auxl) item references. The attack chains four conditions: (1) transfer_channel_from_image_as() accepts duplicate destination channels without validation; (2) find_storage_for_channel() returns only the first match, causing mismatch between declared and actual channel bit depths; (3) scale_nearest_neighbor() allocates based on the first channel's bit depth but iterates all channels, writing 16-bit samples into 8-bit allocations; (4) iden items bypass dimension checks. An attacker can upload or serve a malicious AVIF file to a Next.js application with image optimization enabled. No authentication is required and the attack is network-accessible. Successful exploitation results in arbitrary code execution with the privileges of the Next.js process. Patches are available in Next.js versions 15.5.24 and 16.3.3; AVIF optimization is disabled as a temporary mitigation.

## Affected products

- Vercel Next.js >=10.0.0, <15.5.24 or >=16.0.0, <16.3.3

## Timeline

- 2026-08-25: disclosed: Vulnerability published in GitHub Advisory Database
- 2026-08-25: patched: Patches released as Next.js 15.5.24 and 16.3.3
- 2026-09-08: advisory: Advisory reviewed and updated in GitHub Advisory Database

## References

- [https://github.com/strukturag/libheif/security/advisories/GHSA-g89c-p67h-r497](https://github.com/strukturag/libheif/security/advisories/GHSA-g89c-p67h-r497)
- [https://github.com/vercel/next.js/security/advisories/GHSA-2xp9-vwfh-vxw4](https://github.com/vercel/next.js/security/advisories/GHSA-2xp9-vwfh-vxw4)
- [https://github.com/vercel/next.js/pull/97875](https://github.com/vercel/next.js/pull/97875)
- [https://github.com/vercel/next.js/pull/97931](https://github.com/vercel/next.js/pull/97931)
- [https://github.com/vercel/next.js/commit/3a15b4ac6ac8e70b1a9b18ecc18e8434462899b3](https://github.com/vercel/next.js/commit/3a15b4ac6ac8e70b1a9b18ecc18e8434462899b3)
- [https://github.com/vercel/next.js/commit/409772ec807def20132d251ad48fd8d8ad4c73c2](https://github.com/vercel/next.js/commit/409772ec807def20132d251ad48fd8d8ad4c73c2)

## Related threats

- [Vercel Next.js remote code execution in use cache functions](https://junglewise.ai/threats/next-js-unauthenticated-remote-code-execution-in-use-cache-functions-ac3e73d3)
- [Next.js denial of service in App Router with Server Actions](https://junglewise.ai/threats/cve-2026-94482-next-js-denial-of-service-in-app-router-using-server-actions)
- [Next.js unauthenticated remote code execution in Image Optimization API](https://junglewise.ai/threats/next-js-unauthenticated-remote-code-execution-in-image-optimization-api-f1b22a87)
- [Next.js information disclosure in Draft Mode via use cache](https://junglewise.ai/threats/cve-2026-94544-next-js-is-a-react-framework-for-building-full-stack-web)
- [Next.js Pages Router response cache key bypass](https://junglewise.ai/threats/cve-2026-94543-next-js-is-a-react-framework-for-building-full-stack-web)
