From harness-claude
Analyzes authentication and authorization patterns (OAuth2, JWT, RBAC/ABAC, MFA), audits security posture against OWASP, and recommends improvements for token lifecycle, permission models, and multi-factor authentication.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:harness-authThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> OAuth2, JWT, RBAC/ABAC, session management, and MFA pattern analysis. Detects authentication and authorization mechanisms, evaluates security posture against OWASP guidelines, and recommends improvements for token lifecycle, permission models, and multi-factor authentication.
OAuth2, JWT, RBAC/ABAC, session management, and MFA pattern analysis. Detects authentication and authorization mechanisms, evaluates security posture against OWASP guidelines, and recommends improvements for token lifecycle, permission models, and multi-factor authentication.
Discover authentication providers. Scan the codebase for auth framework usage:
passport.use(), strategy configurations, passport.authenticate() callsnext-auth config, provider definitions, callback handlers@auth0/nextjs-auth0, auth0-js, management API client initializationfirebase/auth, signInWithPopup, onAuthStateChanged usage@EnableWebSecurity, SecurityFilterChain, UserDetailsServiceAddAuthentication(), [Authorize] attributes, ClaimsPrincipalMap token flows. Trace the authentication lifecycle:
Identify authorization models. Determine how permissions are enforced:
Check for MFA implementation. Look for multi-factor authentication:
otplib, speakeasy, Google Authenticator integration@simplewebauthn/server, hardware key registrationInventory session management. If sessions are used:
Check JWT implementation against OWASP guidelines. Verify:
alg: none vulnerability)iss, aud, exp, iat, and sub at minimumEvaluate OAuth2/OIDC flows. If OAuth2 is used:
Assess password handling. If password authentication exists:
Review authorization enforcement. For each protected resource:
Check session security. If sessions are used:
httpOnly, secure, sameSite=Strict or sameSite=LaxToken lifecycle improvements. Based on analysis findings:
Permission model design. Based on the application's needs:
MFA implementation plan. If MFA is missing or incomplete:
Security hardening recommendations. Prioritized by risk:
Generate implementation guidance. Produce:
OWASP Authentication Verification. Check against OWASP ASVS (Application Security Verification Standard) Level 2:
OWASP Authorization Verification. Check against OWASP ASVS:
Test coverage verification. Check that auth logic is tested:
Verify logging and monitoring. Confirm security events are logged:
Produce the auth audit report. Output a structured summary:
harness skill run harness-auth -- Primary CLI entry point. Runs all four phases.harness validate -- Run after implementing auth changes to verify project integrity.harness check-deps -- Verify auth library dependencies are properly declared and up to date.emit_interaction -- Used at permission model design (checkpoint:decision) when choosing between RBAC and ABAC, and before recommending OAuth2 provider changes.Glob -- Discover auth middleware, guard files, policy definitions, and session configurations.Grep -- Search for JWT signing, password hashing, token validation, and authorization checks.Write -- Generate permission matrices, migration plans, and middleware templates.Edit -- Update existing auth middleware, guards, and token configurations.Phase 1: DETECT
Provider: NextAuth.js v4 in src/app/api/auth/[...nextauth]/route.ts
Strategies: Google OAuth2, GitHub OAuth2, email/password (credentials provider)
Token flow: JWT mode, access token in httpOnly cookie, 30-day expiry
Authorization: Custom middleware in src/middleware.ts checking session.user.role
Roles: admin, member (stored in User table via Prisma)
MFA: Not implemented
Session store: JWT-based (no server-side session)
Phase 2: ANALYZE
Findings:
[HIGH] JWT expiry 30 days is excessive — recommend 1 hour with refresh token
[HIGH] Credentials provider uses bcrypt cost factor 8 — recommend 12
[MEDIUM] No PKCE on OAuth2 flows (NextAuth handles this but verify config)
[MEDIUM] No rate limiting on /api/auth/callback/credentials
[LOW] Role check only in middleware — no API-level authorization guards
[LOW] No audit logging for login events
Phase 3: DESIGN
Recommendations:
1. Switch to database sessions with 1-hour access, 7-day refresh
2. Increase bcrypt rounds to 12 in credentials provider
3. Add rate-limiter-flexible middleware on auth endpoints (5 attempts/15min)
4. Create src/lib/guards/requireRole.ts middleware for API routes
5. Add TOTP MFA via otplib with QR enrollment flow
6. Add auth event logging to audit table via Prisma middleware
Phase 4: VALIDATE
OWASP ASVS V2 status:
V2.1 Password Security: PARTIAL (hashing OK, cost factor low, no breach check)
V2.2 Authenticator Security: FAIL (no MFA)
V2.5 Credential Recovery: PASS (email-based reset via NextAuth)
V4.1 Access Control Design: PARTIAL (roles exist, enforcement incomplete)
Test coverage: 60% — missing tests for role escalation and token expiry
Phase 1: DETECT
Provider: Passport.js with passport-jwt and passport-local strategies
Token flow:
- Access token: RS256 JWT, 15-min expiry, in Authorization header
- Refresh token: opaque, 30-day expiry, in httpOnly cookie
- Token refresh endpoint: POST /auth/refresh
Authorization: CASL abilities defined in src/casl/ability.factory.ts
Roles: super-admin, org-admin, member, viewer (stored in PostgreSQL)
MFA: TOTP via speakeasy, WebAuthn via @simplewebauthn/server
Session: Stateless JWT (no server-side session)
Phase 2: ANALYZE
Findings:
[HIGH] Refresh token not rotated on use — token replay possible
[MEDIUM] CASL abilities not checked on 3 admin endpoints (src/admin/admin.controller.ts)
[MEDIUM] No token blocklist — revoked tokens valid until expiry
[LOW] WebAuthn registration does not verify attestation
[LOW] Login failure logging does not include client IP
Phase 3: DESIGN
Recommendations:
1. Implement refresh token rotation with family tracking in Redis
- On refresh: invalidate old token, issue new pair
- On reuse of old token: revoke entire token family (detect theft)
2. Add @CheckPolicies() decorator to admin.controller.ts endpoints
3. Add Redis-backed token blocklist with TTL = access token lifetime
4. Add attestation verification for WebAuthn with expected origin check
5. Enhance auth logging with IP, user-agent, and geolocation
Phase 4: VALIDATE
OWASP ASVS V2 status:
V2.1 Password Security: PASS
V2.2 Authenticator Security: PASS (TOTP + WebAuthn)
V2.8 Multi-Factor: PASS
V4.1 Access Control: PARTIAL (CASL defined, 3 endpoints uncovered)
V4.3 Data-Level: PASS (CASL policies include tenant isolation)
Test coverage: 85% — missing tests for token family revocation
When this skill makes claims about existing code, architecture, or behavior, it MUST cite evidence using one of:
file:line format (e.g., src/auth.ts:42)file with description (e.g., src/utils/hash.ts —
"existing bcrypt wrapper")evidence session section via manage_stateUncited claims: Technical assertions without citations MUST be prefixed with
[UNVERIFIED]. Example: [UNVERIFIED] The auth middleware supports refresh tokens.
These apply to ALL skills. If you catch yourself doing any of these, STOP.
These reasoning patterns sound plausible but lead to bad outcomes. Reject them.
| Rationalization | Reality |
|---|---|
| "No one would guess this token format" | Security by obscurity. Tokens must be cryptographically secure regardless of format predictability. |
| "This is an internal service, auth is less critical" | Internal services are lateral movement targets. Authenticate all service boundaries. |
| "The frontend validates permissions, so the backend doesn't need to" | Client-side checks are bypassable. Server-side authorization is the only real enforcement. |
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeAnalyzes auth mechanisms (passwords/sessions/JWT/OAuth/MFA) and authz patterns (RBAC/ABAC/ACL) for vulnerabilities like bypasses, hijacking, broken access control; reports with OWASP/NIST remediation.
Provides decision trees, JWT references, and patterns for authentication/authorization including OAuth2, sessions, RBAC, ABAC, passkeys, MFA. Use for secure login, tokens, access control.
Audits and hardens authentication code for security vulnerabilities including credential storage, session handling, OAuth/OIDC flows, MFA/passkeys, and OWASP patterns.