Skip to content

Get notified

Get an email when a new major security incident drops. No spam, unsubscribe any time.

Only used for pwn.watch incident emails. Protected by Cloudflare Turnstile.

AppSec & Crypto10 min read

Next.js & React Production Security Checklist (2026)

A production security checklist for Next.js and React Server Components apps: re-check authorization in every route and Server Action instead of trusting middleware, validate data at the RSC and Server Action boundary, patch framework security releases within days, and inventory the endpoints your framework deploys for you.

// key takeaways

  • Middleware is a routing layer, not an authorization boundary. In March 2025 a single crafted x-middleware-subrequest header made self-hosted Next.js skip middleware entirely, along with every auth check that lived there.
  • Server Actions and RSC requests are network endpoints that anyone can call. Authenticate, authorize and schema-validate inside each action and data-access function, not only in the page that renders the form.
  • Framework releases now carry critical fixes. On October 14, 2026 Next.js 16.4.1 and 15.5.28 fixed two unauthenticated RCEs (CVSS 4.0 9.5), one with no workaround but upgrading.
  • Scanners lag vendor advisories. GitHub added the October Next.js SVG advisory to its global database on October 22, eight days after the release, so Dependabot and npm audit stayed quiet for over a week.
  • Frameworks deploy endpoints you did not write. Nuxt Content's default unauthenticated query endpoint shipped denial-of-service and blind SQL injection bugs fixed in October 2026.

What broke in Next.js and React apps in 2025 and 2026

On March 21, 2025 Next.js published an advisory for an authorization bypass in middleware. Sending a crafted x-middleware-subrequest header made self-hosted Next.js skip middleware entirely, so any authentication or authorization check that lived only in middleware stopped running. The GitHub advisory scored it CVSS 9.1. Apps hosted on Vercel were protected; self-hosted apps needed 12.3.5, 13.5.9, 14.2.25 or 15.2.3, or had to strip the header at the edge.

On May 6 and 7, 2026 React and Next.js shipped a coordinated security release: a React Server Components denial-of-service (CVSS 7.5) plus several Next.js advisories covering middleware and proxy bypass, XSS, SSRF, cache poisoning and DoS. The fixed lines were Next.js 15.5.18 and 16.2.6, and react-server-dom-webpack, -parcel and -turbopack 19.0.6, 19.1.7 and 19.2.6. Next.js 13.x and 14.x had no planned patches, so teams still on those majors had no upgrade within their major version.

On October 14, 2026 Vercel shipped Next.js 16.4.1 and 15.5.28 out of band with two critical unauthenticated remote code execution fixes, both rated CVSS 4.0 9.5. The first was a use-after-free in librsvg, bundled through sharp, reachable via the Image Optimization API when SVGs are processed on glibc-based Linux; Netlify noted it was also reachable through next/og ImageResponse. The second hit App Router apps using Cache Components when a use cache function returns multiple typed arrays. A high-severity Server Actions DoS was fixed in the same release. No exploitation was known, but the use cache bug had no workaround.

Never let middleware be the only authorization check

The middleware bypass mattered because many apps put their only session check in middleware.ts and assumed every request reaching a page or route handler had passed it. Once a header could switch middleware off, those pages served data to anonymous users. Middleware (renamed proxy in Next.js 16) is still useful for redirects and coarse gating, but the check that protects data has to run next to the data.

Put session verification and authorization in a server-only data access layer that every Server Component, route handler and Server Action calls before it reads or writes. Check ownership on the record itself, for example by scoping queries to the caller's organization, so a bypass of any outer layer returns nothing useful. At the edge, strip internal framework headers from client requests; that was the documented mitigation for self-hosted apps that could not upgrade straight away.

  • Verify the session in every route handler, Server Component data fetch and Server Action, not only in middleware or proxy.
  • Scope every query by the caller's user or organization ID so a missing check fails closed.
  • Keep authorization helpers in files that import server-only so they can never be bundled to the client.
  • Strip x-middleware-subrequest and other internal x-middleware-* headers from incoming requests at your reverse proxy or CDN.
  • Add a test that calls protected routes with no session and with a forged internal header, and expects 401 or 404.
Strip the internal middleware header at an nginx front
location / {
  # Clients must never set Next.js internal headers (mitigation for the 2025 middleware bypass on self-hosted apps)
  proxy_set_header x-middleware-subrequest "";
  proxy_pass http://nextjs_upstream;
}

Treat Server Actions and RSC payloads as a public API

A Server Action is an HTTP POST endpoint with an ID. Hiding the button does not hide the action: anyone who finds the action ID can call it with any arguments. TypeScript types are erased at runtime, so the argument a client sends is unknown input until you parse it. Two of the 2026 releases fixed Server Actions and RSC denial-of-service bugs, and the October use cache RCE was triggered by the shape of data crossing the serialization boundary, which is why this boundary deserves the same attention as a REST API.

Validate every action argument with a schema, authorize the specific record, and return only the fields the client needs. Do not pass whole database rows into Client Components; everything you pass as props is serialized into the RSC payload that the browser can read. Rate-limit expensive actions the same way you would rate-limit an API route.

  • Parse every Server Action argument with a runtime schema (zod, valibot or similar) and reject unknown keys.
  • Re-check the session and record ownership inside the action, even if the page that renders the form already did.
  • Return minimal DTOs to Client Components; never pass full user or billing rows as props.
  • Keep secrets in server-only modules and never in values that flow into Client Component props.
  • Apply rate limits and body size limits to actions that hit the database, send email or call paid APIs.
Server Action that authenticates, validates and scopes by owner
"use server";
import "server-only";
import { z } from "zod";
import { verifySession } from "@/lib/dal";
import { db } from "@/lib/db";

const RenameProject = z.object({
  projectId: z.string().uuid(),
  name: z.string().trim().min(1).max(100),
}).strict();

export async function renameProject(input: unknown) {
  const session = await verifySession(); // throws or redirects when there is no valid session
  const { projectId, name } = RenameProject.parse(input);
  const updated = await db.project.updateMany({
    where: { id: projectId, orgId: session.orgId }, // ownership check in the query itself
    data: { name },
  });
  if (updated.count === 0) throw new Error("Not found");
  return { ok: true };
}

Patch framework security releases in days, not sprints

Framework security releases now include unauthenticated RCE fixes, so they need the same urgency as an OS or VPN patch. Subscribe to the Next.js and React security blogs and your host's changelog directly. When Vercel released the October fixes on October 14, GitHub did not publish the SVG advisory to its global Advisory Database until October 22, which is when Dependabot and npm audit started flagging affected next versions. Teams that waited for a scanner alert lost eight days.

Check transitive packages as well as next itself. The SVG RCE lived in librsvg inside sharp, fixed in sharp 0.35.5 with librsvg 2.63.2. If you could not upgrade Next.js immediately, sharp's advisory suggested blocking SVG decoding. The May release needed react-server-dom-* upgrades too, and lockfiles often pin those separately. If you run an unsupported major such as Next.js 13.x or 14.x, plan the migration before the next advisory, because the May 2026 release offered no patch for those lines.

  • Follow the Next.js security blog, React blog and your hosting provider's changelog; do not rely only on Dependabot.
  • After upgrading next, confirm sharp resolves to 0.35.5 or later and react-server-dom-* to a fixed version in the lockfile.
  • Keep at least one supported major version; 13.x and 14.x received no fixes in May 2026.
  • Have a tested redeploy path so a framework patch can reach production the same day.
  • Know whether you self-host: the 2025 middleware bypass affected self-hosted Next.js, not apps on Vercel.
Check the versions that actually ship
# Fixed lines after Oct 14 2026: next 16.4.1 or 15.5.28, sharp 0.35.5+
npm ls next sharp react-server-dom-webpack react-server-dom-turbopack

# Fail CI on high or critical advisories once they reach the database
npm audit --omit=dev --audit-level=high

# If you cannot upgrade yet: block SVG decoding in sharp (from sharp's advisory)
# sharp.block({ operation: ["VipsForeignLoadSvg"] });

Inventory the endpoints your framework deploys for you

Modern frameworks add routes you never wrote: image optimizers, OG image generators, Server Action handlers and content query APIs. The October 2026 Next.js SVG RCE was reachable through the Image Optimization API and next/og. Nuxt is no different. On October 21, 2026 the Nuxt Content maintainers published three High advisories for the default, unauthenticated POST /__nuxt_content/:collection/query endpoint in nuxt/content v3.

The Nuxt Content bugs are a textbook case of denylist validation. Its assertSafeQuery check blocked only a small set of SQL keywords and did not reject expensive SQLite functions such as randomblob and zeroblob, so an unauthenticated caller could force large allocations and block the Node event loop. Quote-escape and FROM-matching bugs in the same check allowed boolean-blind SQL injection that could read any table the database user could see, and a third advisory covered cross-table reads. Versions from 3.0.0 up to 3.15.2 were affected; 3.16.2 carries further hardening. Fully static prerendered sites without the API route were not affected, and the documented workaround was to block that POST route at the proxy or WAF.

  • List every route in your production build, including framework-generated ones, and decide which must be public.
  • Block or authenticate framework endpoints you do not use, such as content query APIs on static sites.
  • Prefer allowlists for anything that turns user input into queries; keyword denylists are routinely bypassed.
  • Restrict image optimization to known remote patterns and formats, and avoid processing untrusted SVGs.
  • Upgrade nuxt/content to 3.16.2 or later if you serve its query API.

// actionable engineering checklist

  • Authorize next to the data

    Every Server Component fetch, route handler and Server Action verifies the session and scopes queries by owner; middleware is never the only check.

  • Strip internal headers at the edge

    Drop x-middleware-subrequest and other internal framework headers from client requests at your proxy or CDN.

  • Validate Server Action input

    Parse each argument with a runtime schema, reject unknown keys, and return minimal DTOs.

  • Patch within days

    Next.js 16.4.1 or 15.5.28 (or later), sharp 0.35.5+, and fixed react-server-dom-* versions in the lockfile.

  • Watch vendor advisories directly

    Follow the Next.js and React security blogs; scanners flagged the October 2026 SVG advisory eight days after release.

  • Leave unsupported majors

    Next.js 13.x and 14.x received no fixes in the May 2026 release; schedule the upgrade.

  • Inventory framework endpoints

    Block or authenticate generated routes you do not need, such as POST /__nuxt_content/*/query on static Nuxt sites.

// connected pwn.watch tools & live trackers

Frequently Asked Questions

Is Next.js middleware safe to use for authentication?
It is fine for redirects and coarse gating, but it should never be the only check. The 2025 x-middleware-subrequest bypass made self-hosted Next.js skip middleware entirely. Verify the session again wherever data is read or written.
Can attackers call Server Actions directly?
Yes. Server Actions are POST endpoints identified by an action ID, and anyone who has the ID can send arbitrary arguments. Authenticate, authorize and schema-validate inside every action.
Which Next.js versions fixed the October 2026 RCEs?
Next.js 16.4.1 and 15.5.28, released October 14, 2026. Also make sure sharp resolves to 0.35.5 or later. The use cache RCE had no workaround, so upgrading is the only fix.
Why did npm audit not flag the October Next.js advisory right away?
GitHub published the SVG advisory to its global Advisory Database on October 22, 2026, eight days after the release. Dependabot and npm audit read that database, so follow the framework's own security announcements as well.

Get an email when a new major security incident drops. No spam, unsubscribe any time.