Because the page's check doesn't run when the action is called. A page that renders a form only for admins controls which UI appears; the action behind the form is a separate entry point. Next.js routes a POST to it by the Next-Action header (or, from a form posted without JavaScript, a $ACTION_ID_… field), and any page URL will do.
I showed this on Next.js 16.4.5 under next start. /admin rendered "Not allowed" without a session cookie. A curl POST to /admin with the delete action's id and no cookie ran the action and returned its result. The same request sent to /rt, a page that never used that action, ran it too.
What Next.js does add:
- Origin check. The host in
Originmust matchHostorX-Forwarded-Host; a mismatch is rejected.serverActions.allowedOriginslists extra hosts (behind a proxy whose host differs). A request with noOriginheader is allowed with a warning, so the check stops browsers on other sites, not scripts. CSRF itself belongs to the Web security topic. - Unguessable ids, unused ones stripped. Ids are hashes; the docs say each is cached for at most 14 days. An action is reachable only if its module is compiled into the server bundle.
- Encrypted closures. Values an inline action closes over travel to the client encrypted (per the docs, not run here);
.bindarguments don't. - 1 MB body limit by default (
bodySizeLimit).
None of that knows who the user is. So inside each action, or a server-only data access layer it calls: authenticate from the session (sessions belong to the Authentication topic), authorize this user for this resource (re-read ownership; don't trust an id or object from the client), validate the input, and return only what the UI needs.