GitHub Advisory Database
GHSA-3x4c-7xq6-9pq8
Next.js: Unbounded next/image disk cache growth can exhaust storage
Details
Summary
The default Next.js image optimization disk cache (/_next/image) did not have a configurable upper bound, allowing unbounded cache growth.
Impact
An attacker could generate many unique image-optimization variants and exhaust disk space, causing denial of service. Note that this does not impact platforms that have their own image optimization capabilities, such as Vercel.
Patches
Fixed by adding an LRU-backed disk cache with images.maximumDiskCacheSize, including eviction of least-recently-used entries when the limit is exceeded. Setting maximumDiskCacheSize: 0 disables disk caching.
Workarounds
If upgrade is not immediately possible:
- Periodically clean
.next/cache/images. - Reduce variant cardinality (e.g., tighten values for
images.localPatterns,images.remotePatterns, andimages.qualities)
Affected packages
| Ecosystem | Package | Affected versions |
|---|---|---|
| npm | next | From 16.0.0-beta.0 before 16.1.7 (fixed in 16.1.7) |
| npm | next | From 10.0.0 before 15.5.14 (fixed in 15.5.14) |