kb-security

Provide defensive auth patterns for NextAuth.js v5 and Next.js 16+.

Updated May 19, 2026
One-click install
npx skills add https://github.com/TimeKast/AgendaInteligente --skill kb-security
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kb-security
Source: https://github.com/TimeKast/AgendaInteligente/tree/main/.claude/skills/kb-security
Command: npx skills add https://github.com/TimeKast/AgendaInteligente --skill kb-security

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents common authentication and authorization vulnerabilities in NextAuth.js v5 + Next.js 16+ apps by providing portable, defense-in-depth patterns for session verification, RBAC modeling, input validation, and high-risk flows like password reset.

Core Features & Use Cases

  • Defense-in-depth authorization: Enforces access control across middleware/authorized(), page/server checks, and server-action verification to avoid “one layer only” failures.
  • Portable RBAC matrix modeling: Defines roles and permissions as a roles × actions matrix with default-deny and explicit deny semantics to eliminate ambiguous logic and drift.
  • Zod validation at every boundary: Requires schema parsing for API bodies and server-action inputs to block malformed or malicious data.
  • Attack prevention playbook: Covers SQL injection avoidance (parameterized/ORM queries), XSS-safe rendering and sanitization, and CSRF considerations for custom mutating routes.
  • Password reset hardening: Provides anti-enumeration behavior, hashed token storage, one-time consumption, session invalidation, and rate-limiting guidance.
  • Server-only env hygiene: Reduces accidental secret leakage by enforcing server-only module boundaries and startup env validation.

Quick Start

Use kb-security to review your NextAuth configuration and add Zod-validated permission checks plus a secure password-reset flow that avoids enumeration, hashes reset tokens, and enforces rate limits.

Frequently Asked Questions about kb-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement defense-in-depth authorization in NextAuth.js v5?

RBAC permission checks in NextAuth.js require defining a roles × actions matrix with default-deny semantics. You verify permissions in middleware, page guards, and Server Actions to ensure users only access explicitly granted resources.

How do I secure password reset flows to prevent user enumeration in Next.js?

Password reset hardening prevents enumeration by returning constant responses regardless of email validity. You hash reset tokens, enforce one-time consumption, invalidate active sessions, and apply rate limiting to block brute-force attacks.

How do I validate Server Action inputs with Zod in Next.js 16?

Validating Server Action inputs with Zod requires schema parsing at every boundary to block malformed or malicious data. You define Zod schemas for API bodies and action inputs to prevent injection attacks before processing.

Can I use these security hardening patterns without an existing RBAC matrix?

These security hardening patterns require defining a roles × actions RBAC matrix with default-deny and explicit deny semantics. You model roles and permissions upfront to eliminate ambiguous authorization logic and configuration drift.

What are the limitations of relying only on middleware for NextAuth authorization?

Relying only on middleware creates single-layer failures where bypasses expose unprotected routes. You need additional page-level checks, Server Action verification, and RBAC permission enforcement to achieve defense-in-depth layering.