Install
openclaw skills install bookforge-session-management-security-assessmentSystematically assess web application session management for security vulnerabilities. Use when testing session token generation quality, cookie security configuration, session fixation susceptibility, cross-site request forgery (CSRF) exposure, or session token handling across a session's full lifecycle. Covers the complete taxonomy of generation weaknesses (meaningful tokens with user data embedded, predictable tokens from concealed sequences or time-dependent algorithms or weak pseudorandom number generators, encrypted tokens vulnerable to ECB block rearrangement or CBC bit-flipping) and handling weaknesses (cleartext transmission, token disclosure in server logs or URLs, vulnerable token-to-session mapping, ineffective logout and expiration, client-side hijacking exposure, overly liberal cookie domain or path scope). Use when someone says 'test our session tokens', 'analyze cookie security', 'check for session fixation', 'verify CSRF protection', 'assess token predictability', 'evaluate our session management', 'can session tokens be guessed', 'review logout implementation', 'check cookie flags', or 'audit session security'. Produces a structured vulnerability report with per-weakness findings and remediation guidance. Framed for authorized security testing, defensive security assessment, and educational contexts.
openclaw skills install bookforge-session-management-security-assessmentUse this skill when you are conducting an authorized security assessment of a web application's session management mechanism. Applicable contexts:
This skill covers two orthogonal vulnerability classes: weaknesses in how tokens are generated (can an attacker predict or derive tokens issued to other users?) and weaknesses in how tokens are handled after generation (can an attacker obtain or misuse tokens through network capture, log access, fixation, or client-side attacks?).
Preconditions: You have at least one of:
Agent: This assessment requires authorized access. Confirm scope authorization before beginning any active testing steps. Do not perform active token capture or manipulation against systems you are not authorized to test.
User prompt → Extract: application under test, scope authorization, available artifacts
↓
Environment → Scan for: source files, HTTP logs, config files, cookie headers
↓
Gap analysis → Do I know WHAT to test and DO I have authorized access?
↓
Missing critical info? ──YES──→ ASK (one question at a time)
│
NO
↓
Confirm authorization → PROCEED with systematic assessment
Authorization confirmation: Is this assessment authorized? Who authorized it and for which systems? → Without this, do not proceed with active testing steps.
Application identity: Which application or endpoint is being assessed? → Check prompt for: URL, application name, repository path, or system description.
Available artifacts: What artifacts are available — source code, HTTP proxy history, live access? → This determines which assessment steps can be performed with full confidence vs inferred.
Session token location: How is the session token transmitted? Cookie, URL parameter, hidden form field, custom header?
→ Grep for: Set-Cookie, sessionId, jsessionid, PHPSESSID, ASP.NET_SessionId, token= in URL patterns
→ WHY: The transmission mechanism determines which handling weakness tests apply (e.g., URL transmission exposes to log disclosure; cookies expose to scope and flag issues).
Token generation code: Where and how are tokens generated?
→ Grep for: Random, SecureRandom, uuid, session_start, generateToken, Math.random, rand()
→ WHY: Generation code reveals whether the source of entropy is cryptographically secure.
Cookie attributes: What flags are set on session cookies?
→ Grep for: Secure, HttpOnly, SameSite, domain=, path= in Set-Cookie headers or config
→ WHY: Missing Secure flag allows cleartext transmission; missing HttpOnly enables JavaScript access; overly broad domain= widens attack surface.
Session lifecycle code: How are sessions created, refreshed, and destroyed?
→ Grep for: login handlers, logout endpoints, session invalidation calls (session.invalidate(), session_destroy(), Session.Abandon())
→ WHY: Lifecycle gaps (no token rotation on login, no server-side invalidation on logout) are independent of token strength.
Set-Cookie response headers.Use TodoWrite to track assessment steps before beginning.
TodoWrite([
{ id: "1", content: "Identify session token(s) and transmission mechanism", status: "pending" },
{ id: "2", content: "Assess token generation: meaningful token analysis", status: "pending" },
{ id: "3", content: "Assess token generation: predictability analysis (concealed sequences, time dependency, weak PRNG)", status: "pending" },
{ id: "4", content: "Assess token generation: encrypted token analysis (ECB block rearrangement, CBC bit-flipping)", status: "pending" },
{ id: "5", content: "Run statistical randomness analysis via Burp Sequencer protocol", status: "pending" },
{ id: "6", content: "Assess token handling: network disclosure (HTTPS coverage, Secure flag, HTTP downgrade paths)", status: "pending" },
{ id: "7", content: "Assess token handling: log disclosure (URL-based tokens, admin monitoring exposure)", status: "pending" },
{ id: "8", content: "Assess token handling: token-to-session mapping (concurrent sessions, static tokens)", status: "pending" },
{ id: "9", content: "Assess token handling: session termination (expiration timeout, logout server-side invalidation)", status: "pending" },
{ id: "10", content: "Assess token handling: session fixation (4 test cases)", status: "pending" },
{ id: "11", content: "Assess token handling: CSRF exposure", status: "pending" },
{ id: "12", content: "Assess token handling: cookie scope (domain and path attributes)", status: "pending" },
{ id: "13", content: "Compile findings report with severity ratings and remediation", status: "pending" }
])
ACTION: Identify every item of data that functions as a session token. Do not assume the standard platform cookie is the only token — applications often use multiple items across cookies, URL parameters, and hidden form fields. Confirm which items are actually validated by the server for session state.
WHY: Applications may employ several items collectively as a token, using different components for different back-end subsystems. The standard session cookie generated by the web server may be present but not actually used. Additionally, an item that appears to be a session token may be ignored by the server, meaning its modification would go undetected — a finding in itself. Narrowing the actual validated components reduces wasted analysis effort on inert data.
Detection method:
Also check for alternatives to sessions:
Mark Step 1 complete in TodoWrite.
ACTION: Determine whether session tokens encode user-identifiable or predictable information (username, email, user ID, role, timestamp, IP address) in raw, encoded, or obfuscated form.
WHY: A token that encodes the username — even if hex-encoded or Base64-encoded — allows an attacker to construct valid tokens for any known user without interacting with the server. The apparent complexity of the token string is irrelevant if the underlying data is structured and user-specific.
Test procedure:
= signs or charset a-z A-Z 0-9 +/ (Base64 signatures), repeated character sequences matching username length.If meaning is found:
Mark Step 2 complete in TodoWrite.
ACTION: Assess whether token values follow sequences that allow extrapolation to other users' tokens, even when the tokens do not contain meaningful user data. Investigate three predictability sources: concealed sequences, time dependency, and weak pseudorandom number generator (PRNG) output.
WHY: A token without meaningful user data can still be predictable if it follows an arithmetic sequence or is derived from observable inputs like the current time. An attacker who obtains a sample of tokens can reverse-engineer the generation algorithm and construct tokens issued to other users — without needing any user-specific information.
3a. Concealed Sequences
Tokens may appear random in raw form but reveal arithmetic sequences after decoding. Test:
3b. Time Dependency
Some token generation algorithms incorporate the current time (epoch milliseconds, microseconds) as a primary input. Test:
System.currentTimeMillis(), time(), microtime(), Date.now(), or similar time sources used in token construction.3c. Weak PRNG
Linear congruential generators (LCGs), Math.random(), java.util.Random, PHP's rand(), and similar non-cryptographic PRNGs produce sequences that are fully predictable from a small sample of output values. The next value (and all previous values) can be derived algebraically. Test:
SecureRandom, os.urandom, /dev/urandom, CryptGenRandom are strong. Random, Math.random(), rand(), mt_rand() are weak.Mark Step 3 complete in TodoWrite.
ACTION: Determine whether tokens are encrypted containers for meaningful data, and if so, test for ECB block rearrangement and CBC bit-flipping vulnerabilities.
WHY: Applications that encrypt meaningful session data (user ID, role, username) before issuing it as a token assume that encryption prevents tampering. This assumption fails for ECB ciphers (where ciphertext blocks can be rearranged to produce a different plaintext without knowing the key) and CBC ciphers (where bit-flipping a ciphertext byte produces predictable, controlled changes in the subsequent decrypted block).
Detection — is a block cipher being used?
ECB mode test:
CBC mode test (bit-flipping):
Mark Step 4 complete in TodoWrite.
ACTION: Run a structured statistical randomness test on the session token to quantify effective entropy in bits. This is the authoritative test for token generation quality when visual inspection or manual decoding does not reveal a pattern.
WHY: A token that passes visual inspection and manual analysis may still fail formal statistical randomness tests. Conversely, a token that fails statistical tests may not be practically predictable if the failing bits are sparse across many positions. The key metric is effective entropy (bits of the token that pass randomness tests): a 50-bit token with 50 random bits is equivalent to a 1,000-bit token with only 50 random bits.
Collection protocol:
GET / unauthenticated, or POST /login after authentication). Send this request to Burp Sequencer via the context menu.Interpreting Burp Sequencer results:
Important caveats:
Mark Step 5 complete in TodoWrite.
ACTION: Verify that session tokens are never transmitted in cleartext over unencrypted HTTP, and that cookie Secure flags are correctly set to enforce this.
WHY: A network eavesdropper positioned at any point between client and server — the user's local network, corporate network, ISP, hosting provider — can capture cleartext HTTP traffic. A captured session token grants full session access without knowing user credentials. Even applications that use HTTPS for most content frequently have specific paths (static assets, pre-authentication pages, login forms that accept HTTP) that leak the session token.
Test procedure:
Set-Cookie headers for the Secure flag. If Secure is absent, the browser will transmit the cookie over HTTP to any path/domain match, including unencrypted requests.http:// instead of https://.http:// and check whether the token is transmitted.Secure flag) or the browser warns (mixed content). Treat either as a vulnerability.Mark Step 6 complete in TodoWrite.
ACTION: Identify whether session tokens can be read from system logs, monitoring interfaces, or referrer headers due to token transmission in URLs.
WHY: URL-embedded session tokens appear in: web server access logs, browser history, corporate proxy logs, ISP proxy logs, Referer headers sent to third-party servers when the user follows an off-site link from within the authenticated session. Log disclosure differs from network disclosure in that it is often accessible to a much wider range of insiders (helpdesk, IT operations, log aggregation system users) and persists across time.
Test procedure:
jsessionid= in the URL path, token= in query parameters). Grep for: inurl:jsessionid, ?token=, ?session= patterns in captured traffic.Referer headers containing session tokens from other users.Mark Step 7 complete in TodoWrite.
ACTION: Test whether the application correctly maps tokens to sessions, preventing concurrent session abuse and static token reuse.
WHY: Even a cryptographically strong token is useless as a security control if the application accepts multiple concurrent valid tokens for the same user, or issues the same token on every login ("static tokens"). Concurrent sessions allow an attacker who has obtained credentials to use a captured token undetected while the legitimate user is also logged in. Static tokens are permanent access credentials, not sessions — compromising them compromises the account permanently.
Test procedure:
Mark Step 8 complete in TodoWrite.
ACTION: Verify that sessions expire after an appropriate inactivity timeout and that logout actually invalidates the session on the server side.
WHY: A long-lived session token extends the attack window — if a token is captured or guessed, it remains valid for use. A logout function that only deletes the browser cookie without invalidating the server-side session is functionally equivalent to no logout: anyone who captured the token before logout can still use it indefinitely. Client-side cookie blanking is not server-side invalidation.
Test procedure:
Set-Cookie with a blank or expired token value (client-side only), or does it call a server-side invalidation function? Source code review is definitive. If no source code: the Repeater test in step 2 is authoritative.Mark Step 9 complete in TodoWrite.
ACTION: Test four specific scenarios that determine whether an attacker can fix a known token value for a victim, then escalate to authenticated access after the victim logs in.
WHY: Session fixation attacks are possible when an application accepts tokens that it did not itself issue, or when it reuses pre-authentication tokens as post-authentication tokens. The attacker supplies a token to the victim (via URL parameter, cookie injection, or simply knowing the format), the victim logs in, and the attacker then uses the known token to access the victim's authenticated session.
Test procedure — four test cases:
Pre-authentication token reuse: If the application issues session tokens to unauthenticated users (e.g., to track anonymous shopping carts), obtain an unauthenticated token and perform a login. If the application does not issue a new token after successful authentication: it is vulnerable. An attacker can obtain an anonymous token, force the victim to use it (URL fixation), and after the victim logs in, use the same token.
Return-to-login token reuse: Log in to obtain an authenticated token. Return to the login page. If the application serves the login page without issuing a new token (the existing authenticated token is still active): log in again as a different user using the same token. If the application does not issue a new token on the second login: it is vulnerable to fixation between accounts.
Attacker-supplied token acceptance: Identify the format of valid tokens (from Step 1). Construct a token that conforms to the format (correct length, character set) but is an invented value the application did not issue. Attempt to log in while submitting this invented token in the expected location. If the application creates an authenticated session tied to the invented token: the application accepts attacker-supplied tokens, enabling fixation.
Sensitive data fixation (non-login applications): If the application does not use authentication but processes sensitive user data (e.g., payment forms, personal details), apply test cases 1 and 3 in relation to the pages that display submitted sensitive data. If a token set during anonymous usage can be used by another party to retrieve that user's sensitive data: the application is vulnerable to fixation against non-authenticated sensitive operations.
Cross-site request forgery (CSRF) check: If the application transmits session tokens via cookies: confirm whether it is protected against CSRF.
Mark Step 10 complete in TodoWrite.
ACTION: Review all Set-Cookie response headers for domain and path attributes. Determine whether cookie scope is more permissive than necessary, exposing session tokens to other applications or subdomains.
WHY: A cookie scoped to wahh-organization.com is submitted to every subdomain of that organization — including test environments, staging systems, and other applications that may have lower security standards or be accessible to different personnel. A cross-site scripting vulnerability in any application within the cookie's scope can steal tokens from the main application. Cookie scope is often configured at the platform level (web server defaults) rather than by application developers, so it may be unnecessarily broad.
Test procedure:
Set-Cookie headers issued by the application across the full application walkthrough. Note the domain and path values for session token cookies.domain is set: it is more permissive than the default (which scopes cookies to the exact hostname). Identify all subdomains and applications within the specified domain. Any of these can receive the session cookie.domain is set: by default, the browser scopes the cookie to the exact hostname. However, subdomains still receive the cookie (e.g., a cookie set by app.example.com with no domain attribute is still sent to app.example.com, not to other.example.com, but default behavior differs by browser implementation — verify).path is set to / or a broad path: path-based scope restriction provides no meaningful security separation between applications at different URL paths on the same hostname. Client-side JavaScript at any path on the same origin can read cookies regardless of path attribute.Mark Step 11 complete in TodoWrite.
ACTION: Consolidate all findings from Steps 2–11 into a structured vulnerability report with severity ratings and remediation guidance.
WHY: A finding without remediation guidance is incomplete. Each vulnerability class has a corresponding countermeasure; mapping findings to remediations allows the development team to act without additional research.
HANDOFF TO HUMAN — the agent produces the report; the security team or development team prioritizes and implements remediations.
Report format:
# Session Management Security Assessment Report
## Assessment Scope
[Application name, test date, authorization basis, artifacts reviewed]
## Session Token Identification
[Which items function as session tokens, transmission mechanism, alternatives-to-sessions assessment]
## Part 1: Token Generation Weaknesses
### G1: Meaningful Token Content
**Finding:** [Present / Not detected]
**Evidence:** [Decoded token values, correlation with user data]
**Severity:** [Critical if exploitable | Informational if not validated by server]
**Remediation:** Tokens should be opaque server-generated identifiers. Move all session data to server-side session storage. Never encode user-identifiable data in tokens.
### G2: Predictable Token Sequences
**Finding:** [Present / Not detected — specify: concealed sequence / time dependency / weak PRNG]
**Evidence:** [Sample tokens, decoded sequences, difference analysis, PRNG identification]
**Severity:** [Critical if directly exploitable | High if requires timing correlation]
**Remediation:** Use a cryptographically secure PRNG (CSPRNG) seeded from a high-entropy source (e.g., `SecureRandom`, `os.urandom`, `CryptGenRandom`). Do not use time as a primary entropy source. Do not use linear congruential generators.
### G3: Encrypted Token Vulnerabilities
**Finding:** [ECB block rearrangement / CBC bit-flipping / Not detected]
**Evidence:** [Block cipher detection evidence, manipulation results]
**Severity:** [High — privilege escalation or cross-user access]
**Remediation:** Tokens should not encode sensitive data at all. If encrypted tokens are required, use authenticated encryption (AES-GCM, ChaCha20-Poly1305) to detect any ciphertext modification. Do not use ECB mode. Verify that the entire ciphertext is authenticated before processing any field.
### G4: Statistical Entropy Assessment (Burp Sequencer)
**Finding:** [Effective entropy: X bits. FIPS tests: passed/failed. Notable failures: ...]
**Severity:** [Critical if < 32 bits effective | High if < 64 bits | Low if >= 128 bits]
**Remediation:** Target >= 128 bits of effective entropy. Use platform-provided session management (mature frameworks implement this correctly) rather than custom token generation.
## Part 2: Token Handling Weaknesses
### H1: Network Disclosure
**Finding:** [Cleartext transmission detected / Secure flag absent / HTTP downgrade path found / Not detected]
**Remediation:** Transmit tokens exclusively over HTTPS. Set `Secure` flag on all session cookies. Use HSTS. Redirect HTTP to HTTPS and invalidate any token transmitted over HTTP. Issue a fresh token after the HTTP-to-HTTPS transition.
### H2: Log Disclosure
**Finding:** [Token in URL / Admin monitoring exposes token / Not detected]
**Remediation:** Never transmit session tokens in URL query strings or path components. Use POST for token submission or store in cookies. Administrative monitoring functions should display session metadata (user ID, IP, login time) without exposing the token value itself.
### H3: Vulnerable Token-to-Session Mapping
**Finding:** [Concurrent sessions permitted / Static tokens / Segmented token vulnerability / Not detected]
**Remediation:** Issue a unique token per session. Invalidate all existing sessions when a new login occurs (or alert the user of concurrent access). Never reissue the same token to the same user across separate login events.
### H4: Vulnerable Session Termination
**Finding:** [No inactivity timeout / Logout does not invalidate server-side / Client-side-only cookie deletion / Not detected]
**Remediation:** Implement server-side session invalidation on logout that disposes of all session resources and marks the token as invalid. Implement server-side inactivity timeout (10–30 minutes is typical; match business requirements). Do not rely on client-side cookie deletion as the primary termination mechanism.
### H5: Session Fixation
**Finding:** [Pre-authentication token reused / Return-to-login reuse / Attacker-supplied token accepted / Sensitive data fixation / Not detected]
**Remediation:** Issue a fresh session token immediately after successful authentication. Reject tokens that the server did not itself generate. For non-authenticated sensitive data flows, create a new session at the start of the sensitive data sequence.
### H6: Cross-Site Request Forgery
**Finding:** [Vulnerable — state-changing operations accept cross-origin requests without CSRF token / Not detected]
**Remediation:** Implement per-request CSRF tokens in hidden form fields. Validate the CSRF token on every state-changing request. Consider using the `SameSite=Strict` or `SameSite=Lax` cookie attribute. Require re-authentication before critical operations (fund transfers, password changes).
### H7: Overly Liberal Cookie Scope
**Finding:** [Domain attribute broadens scope to: [list domains] / Path attribute is ineffective for security isolation / Not detected]
**Remediation:** Do not set `domain` attribute unless required — the default (exact hostname) is more restrictive. If subdomains must receive the cookie, audit every subdomain for cross-site scripting and other vulnerabilities. Set cookie scope as restrictively as feasible. Prefer `HttpOnly` to reduce JavaScript access.
## Summary
| # | Weakness | Severity | Status |
|---|----------|----------|--------|
| G1 | Meaningful token content | | |
| G2 | Predictable sequences | | |
| G3 | Encrypted token vulnerability | | |
| G4 | Insufficient entropy | | |
| H1 | Network disclosure | | |
| H2 | Log disclosure | | |
| H3 | Token-to-session mapping | | |
| H4 | Session termination | | |
| H5 | Session fixation | | |
| H6 | CSRF | | |
| H7 | Cookie scope | | |
**Priority remediations:**
1. [Most critical — typically: token generation or network disclosure]
2. [Second priority]
3. [Third priority]
**Positive findings:** [Aspects confirmed secure]
Mark Step 12 complete in TodoWrite.
Token generation and token handling are independent failure dimensions. A cryptographically strong token can still be stolen via network interception, log exposure, or session fixation. A token that is never disclosed can still be useless as a security control if the session lifecycle is broken. Assess both dimensions fully, not just whichever is easier.
Statistical randomness tests do not prove cryptographic security. A deterministic algorithm (linear congruential generator, hash of sequential counter) can produce output that passes all FIPS statistical tests while being perfectly predictable by an attacker who knows the algorithm. Effective entropy is a necessary condition, not a sufficient one. Always investigate the generation algorithm in source code when available.
Passing visual inspection is not passing a security test. Session tokens that "look random" to the eye have repeatedly proven predictable under analysis. Structured statistical analysis (Burp Sequencer at 500+ tokens) and algorithmic analysis (source code review) are required for a defensible assessment.
The Secure flag and HTTPS coverage must both be confirmed. An application that uses HTTPS for all its own pages but loads a single static resource over HTTP exposes the session cookie to network capture on that one HTTP request. Coverage must be total, not partial.
Server-side invalidation is the only valid form of logout. Any logout implementation that relies solely on the client deleting its cookie provides no security against an attacker who has already captured the token. Test logout by replaying a captured pre-logout request after the logout action.
Cookie scope is often set at the platform level, not the application level. Platform defaults may scope cookies to a parent domain across all subdomains. The developer may be unaware. Always check domain and path attributes explicitly in the Set-Cookie response headers, not in application code.
Encrypted tokens are not safe from tampering without authentication. ECB mode allows block rearrangement without decryption. CBC mode allows controlled plaintext modification without decryption. Only authenticated encryption (AEAD) prevents ciphertext manipulation. If tokens must encrypt meaningful data, AES-GCM with verification of the authentication tag before any field is processed is the minimum acceptable approach.
Scenario: E-commerce application — suspected meaningful token Trigger: "Our session tokens look like random hex strings but I want to verify they don't encode user data." Process:
a, aa, aaa, b, testuser@example.com.testuser@example.com decodes to a semicolon-delimited string: user=testuser@example.com;app=shop;date=2026-04-06. This is a meaningful token.user= component to a different registered email. Submit to a session-dependent page. Application responds with the other user's account data.Scenario: Banking application — logout verification Trigger: "Verify whether our logout actually terminates sessions." Process:
Set-Cookie: sessionId=; expires=Thu, 01 Jan 1970 00:00:00 GMT — a client-side cookie deletion only. No server-side invalidation call occurs.
Output: High H4 finding. Remediation: implement server-side session invalidation on logout; store session state on server with explicit invalidation on logout request.Scenario: Internal application — Burp Sequencer entropy assessment Trigger: "Custom session token generation was built in-house using Java. Assess token quality." Process:
sessionId cookie.String sessId = Integer.toString(s_SessionIndex++) + "-" + System.currentTimeMillis(); — a sequential counter concatenated with epoch milliseconds. The counter is the primary failure cause; milliseconds provide only limited additional entropy during busy periods.java.security.SecureRandom generating 128-bit random tokens; store all session data in a server-side session store keyed by this token.This skill is licensed under CC-BY-SA-4.0. Source: BookForge — Web Application Hackers Handbook by Unknown.
This skill is standalone. Browse more BookForge skills: bookforge-skills