This blog post provides the instructions to protect against CVE-2025-29927 by creating a new custom rule with Azure Web Application Firewall
Next.js versions prior to 12.3.5, 13.5.9, 14.2.25 and 15.2.3 are vulnerable to bypass authorization checks within a Next.js application, according to a recently published CVE-2025-29927.
It is strongly recommended to upgrade Next.js to a patched version – 12.3.5, 13.5.9, 14.2.25 or 15.2.3.
For Next.js versions 11.x which currently have no patches available, or other applications based on Next.js which cannot be patched immediately - creating a custom rule in Azure WAF can help mitigate this vulnerability. The custom rule will block any request with the header 'x-middleware-subrequest' which is used as part of this attack. Note that this rule is not exploitation-specific rule, but rather a more general approach which would block legitimate sites using auth middleware.
Create a custom rule to mitigate CVE-2025-29927
- In Azure Portal, navigate to your Web Application Firewall, then select 'Settings' -> 'Custom Rules'.
- Click on 'Add Custom Rule' button.
- Give your custom rule a name, like 'CVE202529927', and set its priority from 1-100.
- In the Conditions, select Match Type = 'String', Match Variable = 'RequestHeaders', and 'Header Name' = 'x-middleware-subrequest'.
- Under 'Operation' select 'is', set 'Operator' to 'Regex' and the Match Values to '.*'
- Under 'Then' section, select 'Deny Traffic' to block any request containing this header.
- Click 'OK' to complete editing, then select 'Save' to apply the new rule.
You can find more information about Custom Rules on Azure WAF for Application Gateway here or for Azure Front Door here.
Updated Mar 25, 2025
Version 1.0yuvalpery
Microsoft
Joined September 04, 2023
Azure Network Security Blog
Follow this blog board to get notified when there's new activity