authentication-flow-review
Skill15 starsChanged 5 months agoCC0-1.0View on GitHub
Conducts a comprehensive authentication security review covering login, sessions, tokens, and credential handling. Use when auditing authentication for vulnerabilities.
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
If no target path is given above, review the entire codebase.
- Distinctive: line 58
No secrets in logs; throttle reset email sender.
- Very specific: line 66
No use of user-controlled operators in filters.
- Distinctive: line 91
No logging of passwords, tokens, reset links, or PII.
- Distinctive: line 122
Prefer minimal, drop-in fix snippets over prose.
- Distinctive: line 123
Do not invent files or functions that aren’t present.
- Distinctive: line 133
Write this into a markdown file and place it in the audits/ folder.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Target: $ARGUMENTS
If no target path is given above, review the entire codebase.
Authentication Flow Review
Stack note: The code examples and library references below use Node.js/Express conventions (
bcrypt,jsonwebtoken,zod/joi,req.body, etc.). If the codebase uses a different language or framework, apply the same security principles and adapt the specifics — for example:bcrypt→passlib/Argon2id(Python),spring-security(Java),bcrypt(Go);jsonwebtoken→PyJWT,java-jwt,golang-jwt/jwt;mongoose.set('sanitizeFilter')→ the equivalent ORM sanitization setting. Mark any checklist item Not Applicable if the concept doesn't apply to the detected stack.
Conduct a comprehensive authentication security review:
Check for:
Password hashing
- Uses
bcrypt.hash()with salt rounds ≥ 10 (ideally 12); async, not sync; no double-hashing on updates. bcrypt.compare()used for login.
- Uses
JWT secret/key strength & storage
- Secrets/keys not hardcoded; loaded from env or secret manager; separate keys for access vs refresh.
- Strong entropy (≥256-bit for HS256) or asymmetric (RS256/ES256) with rotation plan.
Token settings
- Access token TTL 5–15 minutes; refresh token TTL 7–30 days; sliding sessions bounded by a max session age.
- JWT
algorithms,issuer (iss),audience (aud),subject (sub),jti,iat,exp, and optionalnbfare enforced inverify.
- Refresh token implementation
- Rotation on every use and reuse detection (if old RT is presented, revoke the whole session family).
- RTs stored in HttpOnly, Secure, SameSite cookie (not localStorage); hashed at rest if persisted; per-device tracking (
jti,ua,ip,expiresAt).
Session invalidation
- On password change/reset, previously issued tokens are rejected (compare
pwdChangedAtor incrementtokenVersionvsjwt.iat).
- On password change/reset, previously issued tokens are rejected (compare
Brute force protection
- Rate limit login/reset/verify endpoints; progressive backoff per username+IP in a fast store (e.g., Redis); optional CAPTCHA after threshold.
Account enumeration defenses
- Generic errors and identical status/timing for “user not found” vs “bad password”; optional jitter.
Password reset flow security
- Reset tokens via
crypto.randomBytes(32), hashed at rest (SHA-256), short TTL (≤ 15–30 min), one-time use, invalidated after success. - No secrets in logs; throttle reset email sender.
- Reset tokens via
Email verification
- One-time, short-TTL verification tokens; server-side verified; no way to mark verified via mass-assignment/body fields.
SQL/NoSQL injection in auth paths
- No use of user-controlled operators in filters; query sanitization enabled; no
$where; parameterized SQL if applicable.
- No use of user-controlled operators in filters; query sanitization enabled; no
AuthZ integrity
- Roles/permissions loaded server-side; deny-by-default; never trust role/claims purely from the JWT payload without verification and (for sensitive ops) a DB check.
Cookie & CSRF configuration (if cookies used)
HttpOnly,Secure,SameSite=Lax|Strict, narrowpath/domain, explicitMax-Age.- CSRF protection on state-changing endpoints and refresh route (double-submit token or same-site strategy).
Input validation & normalization
- Email/username normalization; length & charset checks; password policy; strong schema validation (zod/joi/celebrate).
Mass assignment risks
- Updates whitelist allowed fields; cannot set
role,emailVerified,passwordResetToken, etc., fromreq.body.
- Updates whitelist allowed fields; cannot set
JWT misuse
- No
jwt.decode()for authorization decisions; alwaysjwt.verify()with explicitalgorithms.
- No
Logging & telemetry
- No logging of passwords, tokens, reset links, or PII; structured logs with redaction/allowlist.
Dependency & crypto hygiene
- Maintained
jsonwebtokenandbcryptversions; no custom JWT parser; Node crypto used correctly; no MD5/SHA* for password hashing.
- Maintained
Transport & CORS
- HTTPS enforced; CORS locked to trusted origins; no wildcard credentials; preflight handled safely.
Open redirect /
nextparam- Post-login redirection restricted to vetted paths/origins; no arbitrary
next=redirects.
- Post-login redirection restricted to vetted paths/origins; no arbitrary
Operational controls
- Secret rotation procedure; key separation for environments; monitoring for suspicious auth patterns; alerting on RT reuse.
Provide:
A structured finding report with the following for each issue:
- Title, Severity (Critical/High/Medium/Low), CWE (if applicable), Evidence (file, function, line ranges), and a short Why it matters.
- Exploitability notes and, where safe, a minimal PoC or reproduction steps (no real secrets).
- Remediation: precise code-level fix or config change (snippets welcome), plus defense-in-depth guidance.
- A summary risk score (0–10) and top 3–5 prioritized fixes that reduce risk fastest.
- A checklist diff: which items from the “Check for” list are Pass/Fail/Not Applicable.
Constraints & style:
- Be concrete and cite exact code locations and identifiers.
- Prefer minimal, drop-in fix snippets over prose.
- Do not invent files or functions that aren’t present; if context is missing, mark as Unable to verify and say what code would prove it.
Bonus (if applicable):
- Suggest hardening improvements (e.g., switching to RS256 with KMS-managed keys, adding
jtiblacklist service, adding device/session management UI, enablingmongoose.set('sanitizeFilter', true)). - Provide quick tests to validate fixes (e.g., RT reuse test, password-changed invalidation test, NoSQLi payload test).
Provide specific vulnerabilities found with severity ratings.
Write this into a markdown file and place it in the audits/ folder.
In this repository21 other files it gives its agents.
- api-and-infrastructureSkill
- authorization-implementationSkill
- business-logic-vulnerabilitiesSkill
- code-duplication-detectionSkill
- code-quality-metrics-standardsSkill
- comprehensive-security-reportSkill
- database-securitySkill
- design-pattern-implementationSkill
- error-handling-resilienceSkill
- exception-flow-analysisSkill
- file-handling-business-logicSkill
- initial-security-analysisSkill
- initial-software-design-analysisSkill
- input-validationSkill
- logging-monitoringSkill
- readability-and-namingSkill
- resilience-fault-toleranceSkill
- secrets-management-auditSkill
- session-cookie-securitySkill
- solid-principlesSkill
- testing-implementationSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

