/qa-auth-flows:session-management-test-authorfrom qa-auth-flows
Authors session-management tests against OWASP ASVS V3: cookie flags, session-ID regeneration, timeouts, concurrent limits, logout semantics, and CSRF binding.
Ships in qa-auth-flows. 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.
This build-an-X workflow authors tests for the session layer against
OWASP ASVS V3 (Session Management): cookie attributes, timeout
behavior, session-ID regeneration, and logout semantics. Cite requirements
in the versioned form v<version>-<chapter>.<section>.<requirement> (e.g.,
v5.0.0-1.2.5) so assertions stay stable across releases.
Every session cookie MUST set:
| Attribute | Required value | Why |
|---|---|---|
Secure | true (in production) | Prevents transmission over plaintext HTTP |
HttpOnly | true | Prevents JavaScript access (XSS impact reduction) |
SameSite | Strict or Lax | CSRF defense |
Path | scope to app root or narrower | Limits cookie exposure |
Domain | NOT a parent domain (avoid subdomain leak) | Limits cookie exposure |
Max-Age or Expires | finite (absolute timeout) | Session can't outlive intended lifetime |
Test pattern (Python with requests):
def test_session_cookie_has_all_required_attributes(client, base_url):
response = client.post(f"{base_url}/login", data={"user": "alice", "pass": "alicepass"})
set_cookie = response.headers.get("Set-Cookie", "")
assert "Secure" in set_cookie
assert "HttpOnly" in set_cookie
assert "SameSite=Strict" in set_cookie or "SameSite=Lax" in set_cookie
assert ("Max-Age" in set_cookie) or ("Expires" in set_cookie)
# Domain attribute should NOT include parent domain:
if "Domain=" in set_cookie:
domain = set_cookie.split("Domain=")[1].split(";")[0]
assert not domain.startswith(".") # no leading-dot (parent domain)
Default: SameSite=Strict - provides the strongest CSRF defense by blocking the cookie on all cross-site requests. Use SameSite=Lax only when the session must survive OAuth callback redirects or other top-level cross-site navigations.
When a user logs in, the session ID MUST change. Otherwise an attacker who set a known session ID on the victim's browser can hijack the post-login session.
Test pattern:
def test_session_id_regenerates_on_login(client, base_url):
# Pre-login: visit homepage, get session cookie
pre_login = client.get(f"{base_url}/")
sid_before = parse_cookie(pre_login, "sessionid")
# Login (carry the pre-login cookie)
client.post(
f"{base_url}/login",
data={"user": "alice", "pass": "alicepass"},
cookies={"sessionid": sid_before},
)
# Post-login: session ID must differ
sid_after = parse_cookie(client.get(f"{base_url}/dashboard"), "sessionid")
assert sid_after != sid_before
If the test fails (session ID unchanged), mark critical: session-fixation vulnerability.
Two timeout dimensions:
Either alone is insufficient - both should be enforced.
Test pattern:
def test_idle_timeout(client, base_url, freezer):
freezer.move_to("2026-05-06 09:00:00")
client.login("alice", "alicepass")
# Activity 5 minutes later: still works
freezer.tick(timedelta(minutes=5))
assert client.get(f"{base_url}/dashboard").status_code == 200
# No activity for 31 min: should expire
freezer.tick(timedelta(minutes=31))
response = client.get(f"{base_url}/dashboard")
assert response.status_code == 401 # or redirects to login
def test_absolute_timeout(client, base_url, freezer):
freezer.move_to("2026-05-06 09:00:00")
client.login("alice", "alicepass")
# Continuous activity should NOT extend beyond absolute limit
for _ in range(8 * 6): # 8 hours of activity, 10-min intervals
freezer.tick(timedelta(minutes=10))
client.get(f"{base_url}/dashboard")
# 8h elapsed: even with continuous activity, session expires
freezer.tick(timedelta(minutes=1))
assert client.get(f"{base_url}/dashboard").status_code == 401
Some apps cap concurrent sessions (e.g., banking apps to 1): either the older session is revoked or the second login is rejected. Document the policy, then test it - pattern in references/session-test-patterns.md.
When a user logs out from one device, all their sessions on that device must be invalidated. Bonus: server-side invalidation (vs just clearing the cookie client-side) prevents replay.
Test pattern:
def test_logout_server_side_invalidation(client, base_url):
client.login("alice", "alicepass")
cookie_value = client.cookies.get("sessionid")
client.post(f"{base_url}/logout")
# Replay the cookie value:
response = requests.get(
f"{base_url}/dashboard",
cookies={"sessionid": cookie_value},
)
assert response.status_code == 401
If the replay succeeds, the server is only clearing the client cookie - critical finding for high-security apps.
Multi-device "logout from all devices" pattern: references/session-test-patterns.md.
For cookie-based sessions, every state-changing endpoint should require a CSRF token (or use SameSite=Strict cookies, which provides similar guarantees).
Test pattern:
def test_csrf_token_required(client, base_url):
client.login("alice", "alicepass")
# Request without CSRF token
response = client.post(f"{base_url}/transfer", json={"to": "bob", "amount": 100})
assert response.status_code in [403, 419] # CSRF rejection
def test_csrf_token_per_session(client, base_url):
client.login("alice", "alicepass")
# Get the CSRF token via the standard endpoint
csrf_response = client.get(f"{base_url}/api/csrf")
token = csrf_response.json()["token"]
response = client.post(
f"{base_url}/transfer",
json={"to": "bob", "amount": 100},
headers={"X-CSRF-Token": token},
)
assert response.status_code == 200
For high-security apps, bind sessions to additional context.
Default: User-Agent + device-fingerprint binding - strikes the best balance of attack surface reduction vs. false positives on legitimate user activity. Use TLS binding (RFC 8473) when the deployment controls both client and server and requires maximum strength; use IP binding only when the threat model accepts mobile-network churn (frequent re-auth on roaming).
These are policy decisions; the test verifies the chosen binding holds (e.g., a request replaying the cookie under a different User-Agent gets 401). Pattern: references/session-test-patterns.md.
For each app's session layer:
Consolidated with the extended patterns in references/session-test-patterns.md.
oauth-flow-test-author.oauth-flow-test-author -
companion: pre-session auth flowkeycloak-tests,
auth0-tests,
okta-tests - IdP-specific session
patterns (federated SSO)evals/an-api-key-revoked-by-a-link-nobody-meant-to-click/criteria.json (opens in a new tab)evals/an-api-key-revoked-by-a-link-nobody-meant-to-click/task.md (opens in a new tab)evals/clinician-sessions-that-have-been-open-for-weeks/criteria.json (opens in a new tab)evals/clinician-sessions-that-have-been-open-for-weeks/task.md (opens in a new tab)evals/marketing-wants-the-session-cookie-on-the-blog-subdomain/criteria.json (opens in a new tab)evals/marketing-wants-the-session-cookie-on-the-blog-subdomain/task.md (opens in a new tab)evals/set-cookie-on-login-mistaken-for-regeneration/criteria.json (opens in a new tab)evals/set-cookie-on-login-mistaken-for-regeneration/task.md (opens in a new tab)evals/stolen-laptop-and-the-sign-out-everywhere-button/criteria.json (opens in a new tab)evals/stolen-laptop-and-the-sign-out-everywhere-button/task.md (opens in a new tab)references/session-test-patterns.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
6 skills in this plugin
/auth0-testsUse when an app uses Auth0 and needs tests for its tenant config, login flows or Action scripts: per-PR or namespaced tenants, Universal Login, PKCE, client credentials, Rules and Hooks, and config drift with a0deploy. Generic OAuth flows are oauth-flow-test-author./keycloak-testsUse whenever an app uses self-hosted Keycloak and needs integration tests: a throwaway Keycloak per test class via Testcontainers, realm JSON imports, OIDC discovery, token and introspection endpoints, the admin REST API, password, auth-code, client-credentials and token-exchange flows, and UMA./mfa-flow-test-authorUse when multi-factor login needs automated tests or a new second factor is being added: deterministic TOTP and HOTP codes, SMS or email OTP, WebAuthn passkeys via the Chrome virtual authenticator, recovery codes, enrollment and step-up challenges./oauth-flow-test-authorUse whenever an OAuth 2.0 or OpenID Connect client or resource server needs tests, whatever the identity provider: auth code with PKCE, client credentials, refresh-token rotation and reuse detection, state and nonce checks, scopes and strict redirect-URI matching, per the RFCs./okta-testsUse when an app uses Okta as its identity provider and needs tests for org config, sign-in policies or Identity Engine flows: per-PR or shared orgs, MFA enforcement, factor enrollment, recovery, SCIM provisioning and least-privilege API tokens.npx claudepluginhub testland/qa --plugin qa-auth-flowsOther plugins' skills for the same job