# GHSA-2xp9-vwfh-vxw4: Next.js: Unauthenticated Remote Code Execution in Image Optimization API when AVIF files are used

> Unauthenticated attackers can achieve remote code execution via the Next.js Image Optimization API by uploading malicious AVIF files.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 8 Sep 2026

## What is GHSA-2xp9-vwfh-vxw4?

GHSA-2xp9-vwfh-vxw4 is a code injection vulnerability in next, published on 8 Sep 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

A vulnerability in the underlying `libheif` library used by `sharp` which Next.js uses for image optimization can lead to remote code execution when AVIF files are optimized.

Until a fix has propagated, optimization of AVIF files is disabled.

## Which versions are affected by GHSA-2xp9-vwfh-vxw4?

4 open source packages ship an affected version, including next.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `next` | npm | From 10.0.0 | 15.5.24 |
| `next` | npm | From 10.0.0 | 15.5.24 |
| `next` | npm | From 16.0.0 | 16.3.3 |
| `next` | npm | From 16.0.0 | 16.3.3 |

## How do I fix GHSA-2xp9-vwfh-vxw4?

Upgrade next to a fixed version for your release line: 15.5.24 or 16.3.3.

## Is GHSA-2xp9-vwfh-vxw4 being exploited?

There is no known exploitation of GHSA-2xp9-vwfh-vxw4 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-2xp9-vwfh-vxw4 and fix it if it is affected.

What it is: GHSA-2xp9-vwfh-vxw4 is a code injection vulnerability in next, published on 8 Sep 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-2xp9-vwfh-vxw4 in the wild and no public exploit code.

Affected packages and fixed versions:
- next (npm): affected from 10.0.0; fixed in 15.5.24
- next (npm): affected from 10.0.0; fixed in 15.5.24
- next (npm): affected from 16.0.0; fixed in 16.3.3
- next (npm): affected from 16.0.0; fixed in 16.3.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-2xp9-vwfh-vxw4/ (Markdown: https://insights.sbomify.com/GHSA-2xp9-vwfh-vxw4/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-2xp9-vwfh-vxw4

---
From sbomify Insights: https://insights.sbomify.com/GHSA-2xp9-vwfh-vxw4/
Summaries are generated and may contain mistakes; the official description above is the record.
