/skillry-backend-and-api:auth-session-reviewfrom skillry-backend-and-api
Reviews authentication and session management for common vulnerabilities: weak cookie flags, JWT misconfiguration, CSRF, session fixation, token rotation, and secret leakage. Produces prioritized findings with remediation steps.
Ships in skillry-backend-and-api. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Review the authentication and session management layer of a web application for the concrete vulnerabilities that most commonly appear in production codebases: weak cookie flags, JWT misconfiguration, missing CSRF protection, password hashing with outdated algorithms, session fixation, broken token rotation, and auth-secret leakage in logs. Produce a prioritized list of findings with severity ratings and specific remediation steps — not a generic checklist, but evidence-based findings with file and line references where available.
Skillry 3.0.0 merged these former skills into this one. The procedure below stays the default; when the task matches a row, open only that reference.
| Former skill | Reference | Use for |
|---|---|---|
authz-permission-review | references/authz-permission-review.md | authorization: RBAC/ABAC model, row-level and tenant isolation, IDOR, privilege escalation, default-deny, denied-path responses and tests |
references/authz-permission-review.md.Locate all session and token creation points. Search for every place a session or token is issued — these are the primary attack surface:
jwt.sign(
session.create(
res.cookie(
createToken(
generateSession(
signIn( # NextAuth
List every file and line. A token issuer that is not reviewed is a blind spot.
Audit cookie flags on every session and auth cookie. For every res.cookie(name, value, options) call, verify all five flags:
httpOnly: true — prevents JavaScript access, mitigates XSS-based session theft.secure: true — prevents transmission over plain HTTP; this must be true in production (controlled by env).sameSite: 'Strict' or 'Lax' — 'None' requires explicit justification and forces secure: true. Default is browser-dependent and should never be relied on.path: '/' and domain scoped to the minimum necessary (not domain: 'example.com' when app.example.com is sufficient).maxAge or expires set to a finite value — a session cookie with no expiry is valid until the browser restarts, not a meaningful bound.Review JWT configuration. If JWTs are used, check every jwt.sign() and jwt.verify() call:
HS256, RS256, or ES256. Never none and never absent (which allows a downgrade attack).jwt.verify() is called with an explicit algorithms whitelist: jwt.verify(token, secret, { algorithms: ['HS256'] }). Without this, a crafted token with alg: none bypasses signature verification entirely.exp) is short: 15 to 60 minutes. Tokens that do not expire are credentials that cannot be revoked.Check for session fixation vulnerabilities. After a successful login, a new session ID must be generated. The pre-login anonymous session ID must not be reused. Search for:
req.session.userId = user.id
without a preceding req.session.regenerate() call (Express-session pattern). Session fixation allows an attacker who obtained the pre-login session ID to instantly gain an authenticated session after the victim logs in.
Verify CSRF protection on state-changing endpoints. For cookie-based sessions:
POST, PUT, PATCH, and DELETE endpoints, or that sameSite: 'Strict' or 'Lax' is set on the session cookie (which provides CSRF protection in modern browsers for same-site navigation).POST methods (ignoreMethods: ['POST']) — this is a footgun that disables the protection entirely.Authorization header (not in cookies): CSRF is not a risk because cookies are not automatically sent with cross-origin requests.Review password hashing at every hashing site. Find all registration, password change, and import flows where passwords are hashed:
bcrypt (cost factor ≥ 12), argon2id (recommended for new implementations), or scrypt. Never md5, sha1, sha256, or sha512 used directly as a KDF — these are message digests, not password hashing functions.bcrypt.compare(), argon2.verify()) — not bcrypt.hash(input) === storedHash (timing oracle).Audit the password reset flow end-to-end. Check:
crypto.randomBytes(32).toString('hex') (Node.js), secrets.token_urlsafe(32) (Python). Never Math.random().Review token refresh and rotation. If refresh tokens are used:
Scan for auth-secret leakage in logs. Search auth-related files for logging calls and confirm they do not include:
httpOnly, secure, sameSite, scoped domain, and finite maxAge.maxAge is set — no cookie is indefinitely valid.verify() — none is structurally impossible.req.session.regenerate() is called immediately after a successful login (session fixation prevention).sameSite is Strict/Lax.POST in its ignoreMethods list.bcrypt (cost ≥ 12) or argon2id — not sha256, sha512, or md5.compare() function.crypto.randomBytes(32) or equivalent.# Locate all session and token creation points
rg --type ts "jwt\.sign\|session\.create\|res\.cookie\|createToken\|generateSession" src/
rg --type py "jwt\.encode\|session\.create\|set_cookie\|create_token" app/
# Check JWT verify calls for missing algorithms whitelist
rg --type ts "jwt\.verify" src/
# Each match should have: { algorithms: ['HS256'] } in the options argument
# Check for session fixation: session.userId assignment without regenerate
rg --type ts "req\.session\." src/auth/ | grep -v "regenerate"
# Audit cookie flags: look for res.cookie calls and check their option objects
rg --type ts "res\.cookie(" src/
# Find password hashing sites
rg --type ts "bcrypt\.\|argon2\.\|crypto\.createHash\|md5\|sha256" src/
# Scan for secrets/tokens in log statements
rg --type ts "console\.log\|logger\.(info|debug|warn)" src/auth/ | grep -i "token\|session\|password\|secret\|jwt"
# Check if reset token is stored plaintext (bad) vs hashed (good)
rg --type ts "resetToken\|passwordResetToken" src/ | grep -v "hash\|bcrypt\|crypto"
# Find CSRF middleware config and any ignoreMethods
rg --type ts "csrf\|csurf" src/ middleware/
rg --type ts "ignoreMethods" src/
# Check password comparison method
rg --type ts "=== .*(hash\|password)\|hash.*===" src/ # timing oracle pattern — flag these
rg --type ts "bcrypt\.compare\|argon2\.verify\|crypto\.timingSafeEqual" src/ # correct pattern
// Correct Express session cookie configuration
res.cookie('sid', sessionId, {
httpOnly: true,
secure: process.env.NODE_ENV === 'production', // controlled by env
sameSite: 'Lax',
path: '/',
maxAge: 60 * 60 * 1000, // 1 hour in ms
});
// Correct jwt.verify with algorithm whitelist
const payload = jwt.verify(token, process.env.JWT_SECRET!, {
algorithms: ['HS256'],
});
// Correct session regeneration after login (Express-session)
req.session.regenerate((err) => {
if (err) return next(err);
req.session.userId = user.id;
res.json({ ok: true });
});
// Correct password reset token: cryptographically random, stored hashed
import crypto from 'crypto';
const raw = crypto.randomBytes(32).toString('hex');
const hashed = await bcrypt.hash(raw, 12);
// send `raw` to the user; store `hashed` in the database
// on verification: bcrypt.compare(submittedRaw, storedHashed)
algorithms whitelist in jwt.verify(). Without { algorithms: ['HS256'] }, a crafted token specifying alg: none bypasses signature verification entirely. This is a critical finding.req.session.regenerate() unconditionally before assigning userId to the session.bcrypt cost factor of 10 or less. The default in many older tutorials is 10, which is too low on current hardware. Use at least 12; 14 for high-value accounts. Make the cost factor configurable from env.localStorage). If the token is not stored server-side, it cannot be revoked on logout or account compromise. A stolen long-lived refresh token from localStorage gives the attacker persistent access.SameSite: 'None' without justification. This opt-out of cross-site cookie restrictions requires Secure: true and a documented reason (cross-origin embedded widget, multi-domain SSO). Without justification it is an unnecessary CSRF risk.debug level. Debug logging that includes the full JWT or session ID is safe in development but devastating when debug logging is accidentally enabled in production. Log only the user ID and request correlation ID.Report must include — with file and line references where available:
regenerate() (or equivalent) is called immediately after login.critical / high / medium / low using CVSS-adjacent reasoning (exploitability × impact).Severity reference:
alg: none bypass, plaintext passwords, no session regeneration, long-lived plaintext reset tokens.Secure flag, missing httpOnly flag, bcrypt cost < 12, no refresh token revocation.sameSite, session cookie with no expiry, reset token expiry > 60 minutes.domain scope.alg: none JWT vulnerabilities and plaintext password storage as critical and surface them immediately, before completing the rest of the review.localStorage for convenience; explain the risk and suggest httpOnly cookies instead.Done means all nine review areas (cookie flags, JWT config, session fixation, CSRF, password hashing, password reset, token rotation, log leakage, and secret entropy) have a finding or a confirmed-clean status, every finding has a severity rating and a specific code-level remediation, findings are ordered by severity, and critical findings are surfaced at the top of the report.
What SKILL.md sets; muted values are Claude Code's defaults
6 skills in this plugin
/transactional-emailSend transactional email and threaded replies via modern mail APIs, author React Email templates, enforce deliverability and release gates./api-and-interface-designDesign APIs and interfaces: REST/GraphQL principles, OpenAPI 3.1 specs, contracts, spec-to-code generation./backend-implementation-reviewReview server-side code: correctness, validation, maintainability, third-party, webhook and queue boundaries.npx claudepluginhub fluxonlab/skillry --plugin skillry-backend-and-apiOther plugins' skills for the same job