🎫 WSTG-SESS: Session Management Testing

OWASP Web Security Testing Guide v4.2

By FixTheVuln Team Sources: OWASP WSTG v4.2
← OWASP WSTG Guide

Session management bridges the gap between authentication and the ongoing user experience. After a user logs in, the application must maintain their authenticated state across multiple requests using session tokens, cookies, or other mechanisms. This category tests whether session identifiers are generated securely, transmitted safely, protected against fixation and hijacking, and properly invalidated on logout. Session management vulnerabilities are particularly dangerous because they allow attackers to take over authenticated sessions without needing the user's credentials. For security professionals, understanding session management is crucial because flaws in this area directly undermine authentication controls, regardless of how strong those controls might be.

Difficulty: Intermediate 9 test cases

OWASP Top 10 Mapping

This testing category relates to the following OWASP Top 10 2021 categories:

A01A07

Quick Reference

Test ID Name CWEs Difficulty
WSTG-SESS-01Session Management SchemaCWE-330, CWE-384Intermediate
WSTG-SESS-02Cookie Attributes TestingCWE-614, CWE-1004Intermediate
WSTG-SESS-03Session Fixation TestingCWE-384Intermediate
WSTG-SESS-04Exposed Session VariablesCWE-200, CWE-598Intermediate
WSTG-SESS-05CSRF TestingCWE-352Intermediate
WSTG-SESS-06Logout TestingCWE-613Intermediate
WSTG-SESS-07Session Timeout TestingCWE-613Intermediate
WSTG-SESS-08Session PuzzlingCWE-384Intermediate
WSTG-SESS-09Session HijackingCWE-384, CWE-614Intermediate

Detailed Test Cases

WSTG-SESS-01: Session Management Schema

Intermediate

This test evaluates the overall session management implementation including how session tokens are generated, their randomness, length, and whether they contain embedded sensitive information. It also checks the session lifecycle from creation through destruction.

Why it matters: The session management schema is the foundation of maintaining authenticated state. If session tokens are predictable, too short, or contain embedded user information, attackers can forge, guess, or extract session tokens to impersonate users.

What to Check

  • Analyze session token length, character set, and entropy
  • Test for predictable patterns by collecting and comparing multiple session tokens
  • Check if session tokens contain encoded user data (Base64 decode to inspect)
  • Verify that new session tokens are generated after authentication events
  • Confirm the session management mechanism is resistant to token prediction attacks
Tools: Burp Suite Sequencer OWASP ZAP Custom entropy analysis scripts
CWE-330 CWE-384

WSTG-SESS-02: Cookie Attributes Testing

Intermediate

This test examines the security attributes set on session cookies, including Secure, HttpOnly, SameSite, Domain, Path, and Expires/Max-Age flags. Missing or misconfigured cookie attributes can expose session tokens to theft through various attack vectors.

Why it matters: Cookie attributes are the primary defense against session token theft. Without the Secure flag, tokens leak over HTTP connections. Without HttpOnly, XSS can steal them. Without SameSite, CSRF attacks can misuse them. Each missing attribute opens a different attack path.

What to Check

  • Verify the Secure flag is set to prevent transmission over HTTP
  • Confirm HttpOnly flag is set to prevent JavaScript access
  • Check SameSite attribute is set to Strict or Lax to prevent CSRF
  • Review Domain and Path attributes for overly broad scope
  • Verify appropriate Expires or Max-Age values are set
Tools: Browser Developer Tools Burp Suite curl OWASP ZAP
CWE-614 CWE-1004

WSTG-SESS-03: Session Fixation Testing

Intermediate

Session fixation testing checks whether the application regenerates the session identifier after successful authentication. Without regeneration, an attacker can set a known session ID before the victim logs in and then use it to access the authenticated session.

Why it matters: Session fixation allows attackers to hijack sessions without needing to steal tokens. By setting the session ID before authentication, the attacker guarantees they know the token that will be associated with the victim's authenticated session.

What to Check

  • Record the session ID before login, then check if it changes after successful authentication
  • Test whether session IDs provided in URL parameters are accepted by the server
  • Check if session IDs can be set through cookie injection techniques
  • Verify that the old session ID is invalidated after a new one is generated
  • Test if session fixation is possible through cross-subdomain cookie injection
Tools: Burp Suite Browser Developer Tools Cookie editor extensions
CWE-384

WSTG-SESS-04: Exposed Session Variables

Intermediate

This test checks whether session tokens or session-related data are exposed through insecure channels such as URLs (Referer header leakage), error messages, logs, or cached pages. Exposed session variables can be captured by third parties or found in server logs.

Why it matters: Session tokens exposed in URLs are particularly dangerous because they appear in browser history, server logs, proxy logs, and Referer headers sent to third-party sites. Any of these exposure points can lead to session hijacking.

What to Check

  • Check if session tokens appear in URLs as query parameters
  • Verify that session data is not leaked through Referer headers to third-party sites
  • Test whether error pages or debug output expose session-related information
  • Check server logs for session token recording
  • Verify that session data is not exposed through browser history or cached pages
Tools: Burp Suite Browser Developer Tools curl Web server log analysis
CWE-200 CWE-598

WSTG-SESS-05: CSRF Testing

Intermediate

Cross-Site Request Forgery (CSRF) testing checks whether the application protects state-changing operations from being triggered by malicious sites that the user visits while authenticated. CSRF exploits the trust that the server places in the user's browser.

Why it matters: CSRF attacks can force authenticated users to perform unintended actions like changing their password, transferring funds, or modifying account settings without their knowledge. The attack works because the browser automatically includes session cookies with every request to the target domain.

What to Check

  • Check for anti-CSRF tokens in forms that perform state-changing operations
  • Verify that anti-CSRF tokens are validated server-side and are unique per session
  • Test if removing or modifying the CSRF token still allows the request to succeed
  • Check SameSite cookie attribute which provides CSRF protection at the browser level
  • Test if sensitive actions can be performed via GET requests (which bypass some CSRF protections)
Tools: Burp Suite CSRF PoC Generator OWASP ZAP Custom HTML forms
CWE-352

WSTG-SESS-06: Logout Testing

Intermediate

This test verifies that the logout function properly destroys the session on the server side, clears session cookies on the client side, and that the session token cannot be reused after logout. Incomplete logout leaves sessions vulnerable to reuse.

Why it matters: If logout does not properly invalidate the session server-side, an attacker who obtained a session token can continue using it even after the legitimate user logs out. This is especially critical on shared computers and in environments where session tokens may have been compromised.

What to Check

  • Verify that clicking logout destroys the session on the server (not just client-side)
  • Test whether the session token can be reused after logout by replaying it
  • Check that session cookies are properly cleared with appropriate expiration values
  • Verify that the back button does not display authenticated content after logout
  • Test if logout invalidates all sessions for the user or only the current one
Tools: Burp Suite Browser Developer Tools curl
CWE-613

WSTG-SESS-07: Session Timeout Testing

Intermediate

This test verifies that sessions expire after an appropriate period of inactivity (idle timeout) and after a maximum absolute lifetime. Sessions that persist indefinitely increase the window of opportunity for session hijacking.

Why it matters: Long-lived or non-expiring sessions dramatically increase the risk of session hijacking because they give attackers more time to discover and use stolen session tokens. Appropriate timeouts limit the damage window and force re-authentication.

What to Check

  • Test the idle timeout by waiting without activity and then attempting to use the session
  • Verify that a maximum session lifetime exists regardless of activity
  • Check if the session timeout is enforced server-side, not just via client-side JavaScript
  • Test whether session timeout values are appropriate for the sensitivity of the application
  • Verify that expired sessions cannot be revived by sending requests with the old token
Tools: Burp Suite Custom timing scripts Browser Developer Tools
CWE-613

WSTG-SESS-08: Session Puzzling

Intermediate

Session puzzling (session variable overloading) occurs when the application uses the same session variable for different purposes across different parts of the application. An attacker can set a session variable in one context and exploit it in another context to bypass security controls.

Why it matters: Session puzzling exploits the shared nature of server-side session storage. When different application functions read and write the same session variables, an attacker can manipulate values through one function to influence the behavior of another, potentially bypassing authentication or authorization.

What to Check

  • Map all session variables used across different application functions
  • Identify session variables that are set in one context and read in another
  • Test whether manipulating session variables through one function affects others
  • Check if unauthenticated functions set session variables used by authenticated functions
  • Verify that session variables have well-defined scopes and purposes
Tools: Burp Suite Manual code review Application-specific testing
CWE-384

WSTG-SESS-09: Session Hijacking

Intermediate

Session hijacking testing evaluates the overall resilience of the session management implementation against various token theft and replay techniques. This includes testing network-level interception, XSS-based theft, and whether additional controls like IP binding or device fingerprinting are in place.

Why it matters: Session hijacking is the culmination of session management weaknesses. If an attacker can obtain and replay a session token, they gain full access to the victim's account. Comprehensive testing ensures that multiple layers of defense protect against this attack.

What to Check

  • Test whether sessions are bound to additional client attributes (IP, User-Agent)
  • Verify that concurrent session limits or alerts exist for the same account
  • Check if the application detects and responds to session token replay from different locations
  • Test whether Man-in-the-Middle attacks can capture session tokens on the network
  • Verify that all session management protections work together as defense in depth
Tools: Burp Suite Wireshark Bettercap Custom scripts
CWE-384 CWE-614

Relevant Certifications

The following certifications cover session management testing concepts:

Security+CEHOSCPCISSP

Frequently Asked Questions

What is session hijacking and how does it work?

Session hijacking occurs when an attacker obtains a valid session token belonging to another user and uses it to impersonate that user. This can happen through network sniffing (if cookies lack the Secure flag), cross-site scripting (if cookies lack HttpOnly), session fixation, or physical access to the user's browser. Once the attacker has the session token, the server cannot distinguish them from the legitimate user.

What is session fixation and how is it different from session hijacking?

Session fixation is an attack where the attacker sets (fixes) the session ID before the victim logs in, rather than stealing it after. The attacker provides a known session ID to the victim (through a crafted URL or cookie injection), waits for the victim to authenticate, and then uses that same session ID to access the authenticated session. Prevention requires regenerating the session ID after successful login.

What cookie security attributes should be set on session cookies?

Session cookies should have the Secure flag (transmitted only over HTTPS), HttpOnly flag (inaccessible to JavaScript, preventing XSS-based theft), SameSite attribute (Strict or Lax, preventing CSRF), appropriate Path and Domain restrictions, and a reasonable expiration. Missing any of these attributes weakens session security.

CyberFolio

Mastering web security testing? Showcase your skills.

Build a free, shareable cybersecurity portfolio that highlights your certifications, projects, and skills.

Build Your Portfolio →

Related WSTG Categories

WSTG-INFO
Information Gathering
WSTG-CONF
Configuration and Deployment Management
WSTG-IDNT
Identity Management
WSTG-ATHN
Authentication Testing
← Back to Home ← All WSTG Categories