Next.js Origin Bypass Vulnerability in Server Action CSRF Validation

Vulnerability

A vulnerability in Next.js versions 16.0.1 prior to 16.1.7 allows requests from opaque contexts, such as sandboxed iframes, to bypass origin verification during Server Action CSRF validation. This could enable an attacker to manipulate a victim's browser into submitting Server Actions from a sandboxed context, potentially executing state-changing actions with the victim's credentials.

Impact

Exploitation of this vulnerability could lead to Cross-Site Request Forgery (CSRF) attacks, allowing unauthorized actions to be performed on behalf of the user.

Reproduction

The vulnerability can be reproduced by sending a request from a sandboxed iframe with the 'null' origin. This can be done by creating an iframe element, setting its 'sandbox' attribute, and appending it to the document. Once the iframe is loaded, a request can be sent to the server action that is vulnerable to CSRF, bypassing the origin validation.

Remediation

Users can upgrade to Next.js version 16.1.7 or later, where this vulnerability is fixed. If an immediate upgrade is not possible, CSRF tokens can be added for sensitive Server Actions, 'SameSite=Strict' can be applied to sensitive authentication cookies, and 'null' can be removed from 'serverActions.allowedOrigins' unless explicitly required and protected.

Added: Mar 18, 2026, 12:21 AM
Updated: Mar 18, 2026, 12:21 AM

Vulnerability Rating

Custom Algorithm
spread
5.2
impact
0.6
exploitability
7.8
remediation
7.9
relevance
4.1
threat
4.8
urgency
2.9
incentive
0.0

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.