Next.js Server-Side Request Forgery and Open Redirect Vulnerability (CVE-2026-64645)
A vulnerability (CVE-2026-64645) in Next.js allows Server-Side Request Forgery (SSRF) and Open Redirect when `rewrites()` or `redirects()` rules in `next.config.js` use attacker-controlled input to construct external destination hostnames, enabling attackers to manipulate dynamic segments from the path or `has` captures to point the rewrite to an arbitrary hostname, potentially leading to internal network access, information disclosure, or redirection of users to malicious sites, affecting Next.js versions from 12.0.0 up to, but not including, 15.5.21, and versions from 16.0.0 up to, but not including, 16.2.11.
What's new
- l2 added detection rule: Detects CVE-2026-64649 Exploitation - SSRF Attempt via Host Header Manipulation Jul 22, 23:12 via ghsa
A high-severity vulnerability, CVE-2026-64645, has been identified in the Next.js framework, affecting versions from 12.0.0 up to 15.5.20 and from 16.0.0 up to 16.2.10. This flaw allows for Server-Side Request Forgery (SSRF) and Open Redirect when an application's next.config.js file contains rewrites() or redirects() rules that construct external destination hostnames using dynamic segments from request-controlled input. An attacker can craft a malicious HTTP request that injects an arbitrary hostname or URL into these dynamic segments, regardless of any intended hostname suffix configured in the rule. This manipulation causes the Next.js application to either proxy requests to an attacker-specified internal or external host (SSRF), or redirect users to a malicious external site (Open Redirect). The vulnerability poses a significant risk for unauthorized access to internal systems, data exfiltration, or successful phishing campaigns.
Attack Chain
- Attacker identifies a Next.js application using vulnerable
rewrites()orredirects()rules that derive external destination hostnames from untrusted user input (e.g., path segments like/:tenantor query parameters like?region=). - The attacker crafts a malicious HTTP request by inserting an arbitrary hostname, IP address, or full URL (e.g.,
http://internal-service.com/apior192.168.1.1/admin) into the dynamic segment of the request path or query parameter. - The Next.js application, processing the request, substitutes the attacker-controlled input into the
destinationfield of thenext.config.jsrewrite or redirect rule without proper sanitization. - For a
rewrites()rule, Next.js then proxies the request to the attacker-specified internal or external host (e.g.,https://attacker-controlled.api.example.comorhttp://internal-service.com/api.api.example.com), sending the response back to the client. This constitutes a Server-Side Request Forgery (SSRF). - For a
redirects()rule, Next.js generates an HTTP 30x redirect response, pointing the user's browser to the attacker-specified external URL (e.g.,https://attacker.com/phish). This leads to an Open Redirect. - Successful exploitation via SSRF allows the attacker to access internal network resources, bypass firewall rules, or scan internal networks. Successful exploitation via Open Redirect can be used for phishing attacks, credential theft, or malware distribution by redirecting unsuspecting users to malicious websites.
Impact
If successfully exploited, CVE-2026-64645 can lead to severe consequences, including unauthorized access to an organization's internal network infrastructure. Attackers can leverage Server-Side Request Forgery (SSRF) to scan internal networks, interact with otherwise inaccessible internal services, or bypass network segmentation to exfiltrate sensitive data. In the case of an Open Redirect, users can be redirected to arbitrary malicious websites, facilitating phishing campaigns for credential theft, malware delivery, or other social engineering attacks. The exact number of affected organizations is unknown, but any Next.js application using the vulnerable rewrite/redirect configurations in the specified versions is at risk, across all sectors.
Recommendation
- Upgrade all affected Next.js instances to patched versions: Next.js 15.5.21 or later, or Next.js 16.2.11 or later to remediate CVE-2026-64645.
- As an immediate workaround for CVE-2026-64645, modify your
next.config.jsto ensure that anyrewrites()orredirects()rules do not construct the hostname of an external destination from untrusted user-controlled input. - If dynamic subdomains are required, constrain the input value using regular expressions to allow only hostname-safe characters (e.g.,
value: '(?<region>[a-z0-9-]+)'). - Deploy the provided Sigma rule to your SIEM and monitor for HTTP requests containing URL-forming characters in dynamic path segments or query parameters, as these may indicate attempted exploitation of CVE-2026-64645.
Detection coverage 2
Detects CVE-2026-64645 Exploitation - Next.js SSRF/Open Redirect via crafted dynamic segment
highDetects exploitation attempts against CVE-2026-64645 in Next.js where attacker-controlled input used in rewrites or redirects contains URL-forming characters (e.g., '://', '@') indicating an SSRF or Open Redirect attempt. This rule targets suspicious patterns in dynamic segments of URL paths or query parameters.
Detects CVE-2026-64649 Exploitation - SSRF Attempt via Host Header Manipulation
highDetects CVE-2026-64649 exploitation by identifying HTTP requests where the Host or X-Forwarded-Host header is manipulated to target internal IP addresses or loopback hosts, indicating a Server-Side Request Forgery attempt.
Detection queries are available on the platform. Get full rules →