Next.js: Server-Side Request Forgery in rewrites via attacker-controlled destination hostname (CVE-2026-64645)
Next.js versions 12.0.0 up to but not including 15.5.21, and 16.0.0 up to but not including 16.2.11, contain a vulnerability where rewrites() or redirects() rules that construct external destination hostnames from user-controlled input can be exploited. This allows an attacker to specify arbitrary hostnames, leading to Server-Side Request Forgery (SSRF) in rewrites and Open Redirects in redirects. The issue arises when dynamic segments in the hostname are derived from request input without proper validation.
AI Analysis
Technical Summary
This vulnerability (CVE-2026-64645) affects Next.js rewrites() and redirects() configuration when the destination hostname is dynamically built from user-controlled input. An attacker can manipulate the hostname to point to arbitrary external hosts. For rewrites, Next.js proxies the request to the attacker-controlled host and returns the response as if from the application origin, enabling SSRF. For redirects, the attacker can cause an open redirect to arbitrary URLs. The vulnerability occurs regardless of the hostname suffix specified in the rule. Examples include dynamic subdomains derived from path parameters or query parameters without proper validation.
Potential Impact
An attacker can exploit this vulnerability to perform Server-Side Request Forgery (SSRF) via rewrites, potentially accessing internal or protected network resources through the Next.js server. Additionally, redirects configured this way are vulnerable to open redirect attacks, which can be used for phishing or redirecting users to malicious sites. The vulnerability affects applications that use dynamic hostnames in rewrites or redirects without restricting user input to safe characters.
Mitigation Recommendations
No official patch or fix is currently confirmed. Users should avoid building the hostname of external rewrites() or redirects() destinations directly from user-controlled input. If dynamic subdomains are necessary, constrain the dynamic segment to hostname-safe characters, for example by using a regex like '(?<region>[a-z0-9-]+)'. Monitor the vendor advisory for updates and apply official fixes once available.
Next.js: Server-Side Request Forgery in rewrites via attacker-controlled destination hostname (CVE-2026-64645)
Description
Next.js versions 12.0.0 up to but not including 15.5.21, and 16.0.0 up to but not including 16.2.11, contain a vulnerability where rewrites() or redirects() rules that construct external destination hostnames from user-controlled input can be exploited. This allows an attacker to specify arbitrary hostnames, leading to Server-Side Request Forgery (SSRF) in rewrites and Open Redirects in redirects. The issue arises when dynamic segments in the hostname are derived from request input without proper validation.
CVSS v4.0
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
This vulnerability (CVE-2026-64645) affects Next.js rewrites() and redirects() configuration when the destination hostname is dynamically built from user-controlled input. An attacker can manipulate the hostname to point to arbitrary external hosts. For rewrites, Next.js proxies the request to the attacker-controlled host and returns the response as if from the application origin, enabling SSRF. For redirects, the attacker can cause an open redirect to arbitrary URLs. The vulnerability occurs regardless of the hostname suffix specified in the rule. Examples include dynamic subdomains derived from path parameters or query parameters without proper validation.
Potential Impact
An attacker can exploit this vulnerability to perform Server-Side Request Forgery (SSRF) via rewrites, potentially accessing internal or protected network resources through the Next.js server. Additionally, redirects configured this way are vulnerable to open redirect attacks, which can be used for phishing or redirecting users to malicious sites. The vulnerability affects applications that use dynamic hostnames in rewrites or redirects without restricting user input to safe characters.
Mitigation Recommendations
No official patch or fix is currently confirmed. Users should avoid building the hostname of external rewrites() or redirects() destinations directly from user-controlled input. If dynamic subdomains are necessary, constrain the dynamic segment to hostname-safe characters, for example by using a regex like '(?<region>[a-z0-9-]+)'. Monitor the vendor advisory for updates and apply official fixes once available.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-p9j2-gv94-2wf4
- Osv Schema Version
- 1.4.0
- Aliases
- ["CVE-2026-64645"]
- Ecosystems
- ["npm"]
- Database Specific Severity
- HIGH
- Cvss Version
- 4.0
Threat ID: 6a616bcd9c2644c7f80dbda1
Added to database: 07/23/2026, 01:18:05 UTC
Last enriched: 07/23/2026, 01:22:26 UTC
Last updated: 07/23/2026, 02:31:31 UTC
Views: 4
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.