Server Actions with no auth check inside them
Last updated November 13, 2026
Steps
- Search for "use server" and list every exported action: create, update, delete, invite, checkout, admin tools.
- At the top of each action, get the current user from the session on the server and return an error if there isn't one. Don't trust a userId passed in from the form.
- Then check authorization: does this user own the record, or have the role, for this specific change?
- Validate the input (for example with a schema) and only update the fields you expect.
- Return only what the UI needs, not full database rows. Next.js also warns that values captured in closures inside actions are sent to the client and back, so don't capture secrets.
- Rate limit sensitive actions such as sending email, inviting users or calling AI models.
- Test it: sign in as a regular user and replay an admin action's request with a different ID. It should fail.
Why it matters
The Next.js data security guide says Server Actions are reachable by direct POST requests even when not imported elsewhere, and that a page-level auth check doesn't extend to the actions defined in it. OWASP lists broken function level authorization (API5:2023) as a top API risk: regular users reaching admin functions because the server never checks.
Sources
Next.js Docs: Data Security (Server Actions) — https://nextjs.org/docs/app/guides/data-security
Next.js Docs: Authentication — https://nextjs.org/docs/app/guides/authentication
OWASP API Security Top 10 2023, API5 Broken Function Level Authorization — https://owasp.org/API-Security/editions/2023/en/0xa5-broken-function-level-authorization/
OWASP Authorization Cheat Sheet — https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html
Related patterns
- Auth checked only in Next.js middleware (proxy)
- API routes with no auth check
- Mass assignment: users can set fields like role or is_admin
- No rate limiting on login, signup or AI endpoints
- Cookie-based login with no CSRF protection on state-changing requests
- Checkout prices, totals and discounts taken from the browser
- AI features that can take actions you never meant to allow (excessive agency)
Found a problem you'd rather not fix yourself?
Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.
Get it fixed by StorenTechVibe Security Weekly
One email a week with new failure patterns and how to fix them.
By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.