Next.js Content Injection Vulnerability for Image Optimization
Description
Next.js is a React framework for building full-stack web applications. In versions before 14.2.31 and from 15.0.0 to before 15.4.5, Next.js Image Optimization is vulnerable to content injection. The issue allowed attacker-controlled external image sources to trigger file downloads with arbitrary content and filenames under specific configurations. This behavior could be abused for phishing or malicious file delivery. This vulnerability has been fixed in Next.js versions 14.2.31 and 15.4.5.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
nextnpm | >= 0.9.9, < 14.2.31 | 14.2.31 |
nextnpm | >= 15.0.0, < 15.4.5 | 15.4.5 |
Affected products
1Patches
16b12c60c61eefix(next/image): fix image-optimizer.ts headers (#82114)
3 files changed · +18 −1
packages/next/src/server/image-optimizer.ts+0 −1 modified@@ -634,7 +634,6 @@ export async function fetchInternalImage( const mocked = createRequestResponseMocks({ url: href, method: _req.method || 'GET', - headers: _req.headers, socket: _req.socket, })
test/integration/image-optimizer/app/pages/api/conditional-cookie.js+11 −0 added@@ -0,0 +1,11 @@ +const pixel = + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg==' + +export default function handler(req, res) { + if (req.headers['cookie']) { + res.setHeader('content-type', 'image/png') + res.end(Buffer.from(pixel, 'base64')) + } else { + res.status(401).end('cookie was not found') + } +}
test/integration/image-optimizer/test/util.ts+7 −0 modified@@ -308,6 +308,13 @@ export function runTests(ctx: RunTestsCtx) { expect(ctx.nextOutput).toContain(animatedWarnText) }) + it('should not forward cookie header', async () => { + const query = { w: ctx.w, q: 30, url: '/api/conditional-cookie' } + const opts = { headers: { accept: 'image/webp', cookie: '1' } } + const res = await fetchViaHTTP(ctx.appPort, '/_next/image', query, opts) + expect(res.status).toBe(400) + }) + if (ctx.nextConfigImages?.dangerouslyAllowSVG) { it('should maintain vector svg', async () => { const query = { w: ctx.w, q: 90, url: '/test.svg' }
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
6- github.com/advisories/GHSA-xv57-4mr9-wg8vghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2025-55173ghsaADVISORY
- vercel.com/changelog/cve-2025-55173ghsaWEB
- github.com/vercel/next.js/commit/6b12c60c61ee80cb0443ccd20de82ca9b4422dddghsax_refsource_MISCWEB
- github.com/vercel/next.js/security/advisories/GHSA-xv57-4mr9-wg8vghsax_refsource_CONFIRMWEB
- vercel.com/changelog/cve-2025-55173ghsax_refsource_MISCWEB
News mentions
0No linked articles in our index yet.