Security skill · Find and fix
Authentication and session review.
Review how an application authenticates users and manages sessions and tokens, covering password storage, login and reset flows, MFA, session identifiers, cookies, JWT handling, logout and revocation, CSRF, and brute-force limits, then fix gaps and verify with two-account and expired-token tests. Use when auditing login, sessions, API tokens, or "remember me" and password reset features.
Facts
- Category
- Find and fix
- License
- MIT
- Tags
- Code review
- Version
- 1.0.0
- Last updated
- 2026-12-02
- Folder
auth-session-review/- MCP resource
skill://auth-session-review/SKILL.md- Files
- SKILL.md
- LICENSE
- references/session-checklist.md
Original Saasment content. Saasment is in early access; this skill does not require joining it.
Install via MCP or as files
Connect your client to https://www.saasment.com/api/mcp (see client setup) and call get_skill:
{
"name": "get_skill",
"arguments": {
"slug": "auth-session-review"
}
}Or download the .zip and unpack it into your agent's skills directory:
Terminal, from your project root (user-level: ~/.cursor/skills)
mkdir -p .cursor/skills
curl -fsSL https://www.saasment.com/ai-security/skills/auth-session-review/download.zip -o /tmp/auth-session-review.zip
unzip -o /tmp/auth-session-review.zip -d .cursor/skills
# result: .cursor/skills/auth-session-review/SKILL.mdReview SKILL.md before enabling a skill. Skills are instructions your agent will follow.
SKILL.md
--- name: auth-session-review description: Review how an application authenticates users and manages sessions and tokens, covering password storage, login and reset flows, MFA, session identifiers, cookies, JWT handling, logout and revocation, CSRF, and brute-force limits, then fix gaps and verify with two-account and expired-token tests. Use when auditing login, sessions, API tokens, or "remember me" and password reset features. license: MIT metadata: author: Saasment version: "1.0.0" category: both tags: "code-review" --- # Authentication and session review (find and fix) License: MIT. Copyright (c) 2026 Saasment. Source: https://www.saasment.com/ai-security/skills/auth-session-review Authentication decides who is calling; the session or token is what the application trusts afterward. Weak points cluster in a few places: how credentials are stored and checked, how recovery flows prove identity, how long and how widely a session identifier is valid, and what happens at logout, password change, and role change. This skill reviews those in code and configuration. For what an authenticated user may do, use `authz-idor-review`. ## When to use - You audit login, signup, password reset, MFA, SSO callback, API token, or session code. - A pull request changes cookies, JWT handling, or an identity provider integration. - You need a checklist for a pre-release review of an authentication change. ## Safe by default - Review and test only applications and accounts you own or are authorized to test. Create dedicated test users; never use real customers' accounts. - Do not run password guessing or credential stuffing against any system. To check rate limits, send a small number of requests with a test account in a test environment, and stop at the first sign the limit works. - Do not print real tokens, session cookies, or password hashes in notes or reports. Redact all but a few characters. - Do not change production identity provider settings as part of a review. Propose the change and test it in staging. ## Procedure 1. **Inventory identity flows.** List every way to get a session: password login, SSO or OAuth callback, magic link, API key, service token, mobile token refresh, and "remember me". Note which systems issue and verify each. 2. **Review credential storage and checks.** Passwords stored with a slow, salted password hash (Argon2id, scrypt, bcrypt, or PBKDF2 with a high work factor), never reversible encryption or a fast hash (see `crypto-misuse-review`). Login compares in constant time and returns the same message for unknown user and wrong password. 3. **Review abuse controls.** Rate limiting and lockout or backoff per account and per source, with limits that attackers cannot bypass by rotating a header such as `X-Forwarded-For`. CAPTCHA or MFA step-up for repeated failures where appropriate. 4. **Review recovery flows.** Reset tokens are random, single use, short lived, stored hashed, and bound to the account; the response does not reveal whether an email exists; the old sessions end after a reset; email change requires confirmation of the old or new address and the current password. 5. **Review MFA.** Enrolment requires an authenticated session; verification cannot be skipped by calling a later endpoint directly; recovery codes are stored hashed and single use; failed attempts are rate limited; phishing-resistant factors are offered for privileged roles. 6. **Review session identifiers and cookies** (details in `references/session-checklist.md`): high-entropy random identifiers from a vetted library, regenerated at login and privilege change, `Secure`, `HttpOnly`, and an explicit `SameSite` value, narrow `Domain` and `Path`, and a server-side idle and absolute timeout. 7. **Review tokens (JWT and similar).** The verifier pins the allowed algorithms and key, rejects `none`, checks `exp`, `nbf`, `iss`, and `aud`, and uses key identifiers from a trusted key set only. Access tokens are short lived; refresh tokens rotate and can be revoked. Tokens are not stored in places scripts can read when a cookie would do. 8. **Review logout and revocation.** Logout invalidates the server-side session or token family, password change and MFA change end other sessions, deleted or disabled users lose access immediately, and there is a way to list and revoke a user's sessions. 9. **Review CSRF and cross-origin behavior.** State-changing requests authenticated by cookie require an anti-CSRF token or an equivalent same-site control; CORS does not reflect arbitrary origins with credentials; the OAuth `state` and PKCE values are verified. 10. **Fix and test.** Apply fixes in the shared authentication layer, not per route, and add the tests listed under Verification. ## Verification - Confirm session fixation is closed: obtain a session identifier before login, log in, and assert the identifier changed. - Confirm logout works: use a copy of the session cookie or token after logout and assert the API rejects it. - Confirm expiry: set the test clock or use a short-lived token and assert that an expired token is rejected, including by refresh endpoints. - Confirm password reset: use a reset link twice and after expiry, and assert both fail; confirm other sessions end after a successful reset. - Confirm JWT checks with locally generated test tokens that have a wrong signature, an altered algorithm header, a wrong audience, and an expired time; assert each is rejected. - Confirm cookies by reading `Set-Cookie` headers from a test login and checking the flags and lifetimes. - Confirm rate limiting with a handful of failed logins against a test account and assert a 429 or backoff response. ## Reporting Table: id, flow, issue, impact, fix, test. Include a list of flows reviewed and any identity provider settings that need an administrator. ## References - OWASP Authentication Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html - OWASP Session Management Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html - OWASP Password Storage Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html - OWASP Cross-Site Request Forgery Prevention Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html - NIST SP 800-63B digital identity guidelines: https://pages.nist.gov/800-63-3/sp800-63b.html - Companion skills: `authz-idor-review`, `crypto-misuse-review`, `secure-code-review-checklist`.
Helper files
LICENSE
MIT License Copyright (c) 2026 Saasment Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
references/session-checklist.md
# Session, cookie, and token checklist License: MIT. Copyright (c) 2026 Saasment. Use this table while reading code or inspecting headers from a test login. ## Cookie attributes | Attribute | Expect | Why | | --- | --- | --- | | `Secure` | set | Stops the browser sending the cookie over plain HTTP | | `HttpOnly` | set for session cookies | Scripts cannot read it, which limits the damage of XSS | | `SameSite` | `Lax` or `Strict` unless cross-site use is required, then `None` with `Secure` and CSRF defenses | Limits cross-site request forgery | | `Domain` | omitted (host-only) unless subdomains must share it | Narrows who receives the cookie | | `Path` | `/` unless the app is mounted deeper | Avoids accidental sharing | | `Max-Age` or `Expires` | matches the absolute timeout | A session cookie can still outlive a browser session on some clients | | Name prefix `__Host-` | used where possible | Browser enforces `Secure`, `Path=/`, and no `Domain` | ## Server-side session rules | Rule | Check | | --- | --- | | Identifier entropy | at least 128 bits from a cryptographically secure generator, never derived from user data or time | | Regeneration | new identifier at login, MFA completion, and privilege change | | Idle timeout | set, and enforced on the server (not only by cookie expiry) | | Absolute timeout | set, shorter for privileged roles | | Revocation | logout, password change, MFA change, account disable, and admin action end sessions | | Storage | session store authenticated, not reachable from the internet, with expiry | | Concurrency | a user can list and end other sessions | ## JWT and bearer token review | Item | Check | | --- | --- | | Algorithm | allowlist pinned in verification code, no fallback to the header's `alg`, `none` rejected | | Keys | symmetric secret is long and random, or asymmetric public key from a trusted set; key id lookups cannot load arbitrary URLs | | Claims | `exp`, `nbf`, `iss`, `aud` verified; `sub` used for identity, not an email or name | | Lifetime | access tokens short, refresh tokens rotate and are revoked on reuse | | Storage | cookie with `HttpOnly` preferred for browsers; if web storage is used, the XSS risk is accepted and documented | | Contents | no secrets or unnecessary personal data in the payload (it is encoded, not encrypted) | | Revocation | a strategy exists (short life plus deny list, or reference tokens) | ## Quick header inspection (test environment) ```bash # Show cookie flags from a login response made with a test account curl -si -X POST https://staging.example.test/login \ -d 'user=test-user&password=test-password' | grep -i '^set-cookie' ``` Use a placeholder host you own. Do not run this against systems you are not authorized to test. ## Test matrix | Test | Expected | | --- | --- | | Reuse session id after logout | 401 | | Session id from before login still valid after login | No: id changed | | Expired access token | 401 | | Refresh token used twice | second use rejected and family revoked | | Reset link used twice | second use rejected | | Old password after reset | rejected | | Wrong `aud` or `iss` in a test-signed token | 401 | | Five failed logins on a test account | throttled |
Related
Companion skills
Questions
How do I install the Authentication and session review skill?
Download https://www.saasment.com/ai-security/skills/auth-session-review/download.zip and unzip it into your agent's skills directory (for example .cursor/skills, .claude/skills, .agents/skills, or .github/skills) so that auth-session-review/SKILL.md exists. Or connect to https://www.saasment.com/api/mcp and call the get_skill tool with the slug auth-session-review.
What license is the Authentication and session review skill under?
It is original Saasment content under the MIT license, stated in the SKILL.md frontmatter and in the LICENSE file in the skill folder.
Is it safe to run this skill?
A skill is a set of instructions your agent follows, so read SKILL.md first. It tells the agent to test only systems you own or are authorized to test, to use test environments and synthetic data, and to avoid destructive probes. Downloading it does not run any code on your machine.