Framework Security··6 min read

Securing Next.js Server Actions against BOLA, CSRF, and unauthenticated RPCs

Middleware guards do not protect direct Next-Action POST invocations unless every Server Action verifies session and ownership internally.

Key takeaway

Treat every 'use server' function as a public internet POST endpoint with explicit auth, schema parsing, and row-level ownership checks.

Never trust middleware alone for Server Actions

React and Next.js expose Server Actions directly over POST requests keyed by Next-Action headers. Checking authorization only inside page layouts or route middleware leaves exported actions exposed to direct replay.