CVE-2026-64645: Next.js: Server-Side Request Forgery in rewrites via attacker-controlled destination hostname
Impact
A rewrites() or redirects() rule that builds its external destination hostname from request-controlled input can be pointed at an arbitrary hostname, regardless of the rule's hostname suffix. For a rewrite, Next.js proxies the request to that arbitrary host and serves the response from the application's origin, leading to Server-Side Request forgery. A redirects() rule configured this way is vulnerable to an Open Redirect.
This affects any destination that puts a dynamic segment in the hostname, whether from the path:
javascript // next.config.js module.exports = { async rewrites() { return [ { source: '/:tenant', destination: 'https://:tenant.api.example.com', }, ] }, }
or from a has capture:
javascript // next.config.js module.exports = { async rewrites() { return [ { source: '/', has: [{ type: 'query', key: 'region', value: '(?<region>.+)' }], destination: 'https://:region.api.example.com', }, ] }, }
Workarounds
If you cannot upgrade immediately, do not build the hostname of an external rewrites() or redirects() destination from user-controlled input. If a dynamic subdomain is required, constrain the value to hostname-safe characters: value: '(?<region>[a-z0-9-]+)'.
Other sources
Next.js is a React framework for building full-stack web applications. In versions 12.0.0 through 15.5.20 and 16.0.0 through 16.2.10, a rewrites() or redirects() rule that builds its external destination hostname from request-controlled input can be pointed at an arbitrary hostname, regardless of the rule's hostname suffix. For a rewrite, Next.js proxies the request to that arbitrary host and serves the response from the application's origin, leading to Server-Side Request forgery. A redirects() rule configured this way is vulnerable to an Open Redirect. This issue has been fixed in versions 15.5.21 and 16.2.11.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/nextto a version that resolves this vulnerability.Fixed in 16.2.11 - Upgrade
Upgrade
npm/nextto a version that resolves this vulnerability.Fixed in 15.5.21 - Upgrade
Upgrade
Next.jsto a version that resolves this vulnerability.Fixed in 15.5.21 - Upgrade
Upgrade
Next.jsto a version that resolves this vulnerability.Fixed in 16.2.11 - Configuration
If a dynamic subdomain is required, constrain the value used in the external destination hostname to hostname-safe characters (e.g., use a capture regex such as `value: '(?<region>[a-z0-9-]+)'`).
Next.js rewrites()/redirects() rules destination hostname construction from request-controlled input = Constrain dynamic subdomain values to hostname-safe characters using a capture like '(?<region>[a-z0-9-]+)' - Compensating control
If you cannot upgrade immediately, do not build the external destination hostname for a `rewrites()` or `redirects()` rule from user-controlled input (avoid using request-controlled segments/captures to form an external destination hostname).
Event History
Frequently Asked Questions
What is the severity of CVE-2026-64645?
The severity of CVE-2026-64645 is rated at 71.
What type of vulnerability is CVE-2026-64645?
CVE-2026-64645 is classified as a Server-Side Request Forgery (SSRF) vulnerability.
How do I fix CVE-2026-64645?
To fix CVE-2026-64645, validate and sanitize input used in `rewrites()` and `redirects()` rules to prevent arbitrary hostname targeting.
What software is affected by CVE-2026-64645?
CVE-2026-64645 affects the Next.js framework, specifically versions available through npm.
When was CVE-2026-64645 published?
CVE-2026-64645 was published on July 22, 2026.