session-management-test-author
БесплатноБез исполняемых скриптовНе проверенUse for any question or task about testing sessions, login or logout security in a web app, in any framework, including one login handler and old cookies that…
от testland★ 18 звёзд на GitHubОб этом скилле
session-management-test-author
Overview
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.
When to use
- Authoring tests for any web app with sessions (cookie-based or token-based).
- Reviewing PRs that touch login / logout / session middleware.
- A security audit cites ASVS V3 as a target.
- Compliance program (SOC 2, ISO 27001) requires evidence of session-management testing.
Step 1 - Cookie attribute baseline
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.
Step 2 - Session-fixation defense
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.
Step 3 - Absolute + idle timeout
Two timeout dimensions:
- Absolute timeout: maximum session lifetime regardless of activity (e.g., 8 hours). Common for high-security apps.
- Idle timeout: session expires after N minutes of inactivity (e.g., 30 minutes).
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
Step 4 - Concurrent-session limits
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.
Step 5 - Logout invalidation across devices
When a user logs out from one device, all their sessions on that device must be inva
Установить session-management-test-author в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл session-management-test-author?
Use for any question or task about testing sessions, login or logout security in a web app, in any framework, including one login handler and old cookies that still work after logout: cookie flags (Secure, HttpOnly, SameSite), session ID regeneration on login, idle and absolute timeouts, concurrent-session limits, logout on all devices, CSRF tokens and session binding, per OWASP ASVS V3.
Как установить скилл session-management-test-author?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл session-management-test-author запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic