Next.js: Unauthenticated Remote Code Execution in Image Optimization API
A specially built AVIF image can make a vulnerable Next.js server run attacker commands. No login or user action is required.
- Severity
- Not scoredNo CVSS score recorded
- Fix
- Fixed in 15.5.24, 16.3.3Fix recorded 3 days ago
- Affected versions
- 10.0.0 or newer, but before 15.5.24; 16.0.0 or newer, but before 16.3.3
- Affects
- next
How it works
- The site must optimize an attacker-controlled AVIF image through Next.js.
- Sharp then passes the image to its underlying libheif software.
- Conflicting image-layer details make that software write outside its assigned workspace.
- This can let the attacker run commands on the server.
What to do
Run npm ls next in the application's project directory. Versions from 10.0.0 through 15.5.23, or 16.0.0 through 16.3.2, are affected when AVIF optimization is used. Finding an affected version shows exposure, not proof of compromise.
Run this in the application environment you want to check:
npm ls nextUpgrade the 15.x branch to Next.js 15.5.24 or later. Upgrade the 16.x branch to 16.3.3 or later. Confirm the installed result with npm ls next.
Technical details
Next.js image optimization uses sharp, which relies on libheif for AVIF images. A deliberately constructed image can make libheif write beyond its assigned workspace, potentially allowing remote command execution. The advisory covers next npm releases from 10.0.0 before 15.5.24 and 16.0.0 before 16.3.3. Vercel temporarily disabled AVIF optimization while the corrected dependency propagated.
References
- github.com · v15.5.24 (tag) vendor advisory patch release notes
- github.com · v16.3.3 (tag) vendor advisory patch release notes
- github.com · next.js product
- github.com · GHSA-2xp9-vwfh-vxw4 vendor advisory
- github.com · PR #97875 vendor advisory GitHub Advisory OSV.dev
- github.com · GHSA-g89c-p67h-r497 vendor advisory
- github.com · PR #97931 vendor advisory GitHub Advisory OSV.dev
- github.com · commit 3a15b4a vendor advisory GitHub Advisory OSV.dev
- github.com · commit 409772e vendor advisory GitHub Advisory OSV.dev
- github.com · commit 7a5937a vendor advisory GitHub Advisory OSV.dev
- osv.dev · GHSA-2XP9-VWFH-VXW4 vdb entry OSV.dev