Introducing a new way to review your PRs.

Read the announcement

raroque / vibe-security-skill

Agent skill that audits vibe-coded apps for common security vulnerabilities introduced by AI coding assistants

View on GitHub

15 documents · Updated Oct 30, 2026

docs / authentication-security

Authentication security

Authentication security protects the boundary between an unknown caller and a known identity. This review area checks whether login state, tokens, sessions, and identity checks remain trustworthy across the full request path.

Authentication boundary

The authentication boundary is the point where the system decides who is making a request. A secure review treats every server entry point as reachable by an untrusted caller, even when the request normally comes from a visible page or a prior middleware check.

Request trust model

The request trust model requires each protected operation to establish identity before it uses private data or changes state. Middleware can provide an early filter, but the operation that reads data or performs a change must verify the request again. This prevents a bypass of one request layer from becoming access to the whole system.

The review should trace authentication through these boundary types:

  • Server actions and other public form-like operations.
  • API route handlers.
  • Data access functions and database queries.
  • Any edge or middleware layer that runs before the operation.

References: vibe-security/…/authentication.md• L20-65

Token and session protection

Tokens and sessions carry proof of an earlier identity check. Their protection depends on both how the system validates them and how the browser stores and sends them.

Token validation

Token validation must prove that the token came from the trusted issuer and is still valid for this service. Reading token contents is not proof of authenticity, so the review checks signature verification together with the allowed algorithm, issuer, audience, and expiry.

The main review questions are:

  • Does the system verify the signature rather than only decode the payload?
  • Does it allow only the expected signing algorithm and reject unsigned tokens?
  • Does it check issuer, audience, and expiration for the service?

References: vibe-security/…/authentication.md• L3-18

Browser session storage

Browser session storage controls how much a script injection or cross-site request can expose. Session tokens should use cookies that are hidden from JavaScript and restricted by the browser, rather than storage that any page script can read.

The review checks for HttpOnly, Secure, and an appropriate SameSite setting. It also treats browser-readable token storage as a high-risk choice because one script injection can expose the session to an attacker.

References: vibe-security/…/authentication.md• L86-90

Identity and resource access

Authentication answers who the caller is. Authorization answers whether that caller may use the requested resource. A login check without an ownership or role check can still expose another user’s data or allow an unsafe change.

Operation authorization

Every state-changing operation needs three checks at its boundary: valid input, an authenticated identity, and permission for the requested resource. The permission check must connect the resource to the caller or to an allowed role instead of stopping at “the user is logged in.”

This model applies to both server actions and API handlers because both are public request endpoints. The review should follow the requested resource through the check and confirm that the operation cannot act on an arbitrary identifier supplied by the caller.

References: vibe-security/…/authentication.md• L31-65

Client data exposure

Identity data sent to a client becomes part of the client’s trust boundary. The system should return only the fields needed for the user experience and keep password data, internal identifiers, and administrative fields on the server.

The review checks that data access selects a narrow response shape. It also checks that server-only data access code cannot be imported into client code by mistake.

References: vibe-security/…/authentication.md• L67-84

Identity verification review

Identity verification is the process that links a claimed identity to a trusted account. The review follows that link across login, session creation, token checks, and each protected operation rather than treating any single check as sufficient.

Verification sequence

When a caller uses a protected feature, the system should move through a clear sequence. Each step reduces a different risk and passes only the needed result to the next step.

flowchart TD
    A[Incoming request] --> B[Validate request input]
    B --> C[Verify session or token]
    C --> D[Confirm issuer claims and expiry]
    D --> E[Check resource permission]
    E --> F[Return limited data or perform change]

The sequence separates identity proof from permission to use a resource. This makes it easier to review whether a missing check can turn an invalid token, a stale session, or an unrelated resource ID into access.

References: vibe-security/…/authentication.md• L3-18 vibe-security/…/authentication.md• L31-65

Cross-system relationships

Authentication security is one part of the wider identity and data protection model. It controls entry to protected data, while data access security limits what an authenticated identity can reach and secrets security protects the credentials used to verify that identity.

For the wider system view, see Identity and data protection. For access checks after authentication, see Data access security. For protection of signing keys and other credentials, see Secrets and environment security.

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to token claims or signing rules must stay aligned between token creation and every verification boundary.
  • Changes to session cookie settings must be checked against browser behavior and every request path that depends on the cookie.
  • Changes to route, action, or data access boundaries must preserve both authentication and resource-level authorization.
  • Changes to user response shapes must not re-expose fields that are safe only on the server.

Important failure modes

TriggerConsequenceGuard
The system decodes a token without verifying its signature.An attacker can forge the identity and claims in the token.Verify the signature and validate the allowed algorithm and claims.
Middleware is the only authentication check.A bypass of the early layer can expose protected operations.Verify authentication again in the operation and data access path.
A state-changing operation checks login but not resource ownership.One user can change or read another user’s resource.Check the resource against the authenticated identity or allowed role.
A session token is stored where page JavaScript can read it.A script injection can steal the active session.Use an HttpOnly, Secure, appropriately SameSite cookie.

Key files

FileWhy to read it
vibe-security/…/authentication.mdDefines the review rules for token checks, request boundaries, authorization, client data exposure, and session storage.
docs/identity-and-data-protection.mdParent page for the broader identity and data protection model.
docs/data-access-security.mdRelated guidance for limiting what an authenticated identity can access.
docs/secrets-and-environment-security.mdRelated guidance for protecting keys and credentials used by authentication systems.