Session Management Issues Test Approach

Ajay Monga
3 min readSep 19, 2024

--

1. Session Creation

Vulnerabilities:

Session ID Strength

Approach:

  • Capture session IDs using a proxy tool (e.g., Burp Suite).
  • Analyze the length and randomness of session IDs.
  • Use brute-force tools to guess weak session IDs if patterns are evident.

Mitigation:

  • Use cryptographically secure random numbers for generating session IDs (e.g., using libraries like java.security.SecureRandom).
  • Ensure session IDs are sufficiently long (at least 128 bits of entropy).

Cookie Set with Parent Domain

Approach:

  • Inspect cookies using browser developer tools.
  • Check if the cookie’s domain attribute is set to the parent domain, allowing subdomains access.

Mitigation:

  • Set the cookie’s domain attribute explicitly to the current domain rather than a parent domain.

Cookie Path Attribute Set Insecurely

Approach:

  • Check the path attribute of the cookie to ensure it is not set too broadly.
  • Attempt to access the cookie from a different directory and see if it is accessible.

Mitigation:

  • Set the cookie’s path attribute to the most restrictive path required for the application (e.g., /specific-path/).

Session Puzzling Attack

Approach:

  • Use automated tools to manipulate and guess session identifiers by sending a series of crafted requests.
  • Analyze if the server accepts unauthorized session IDs to access resources.

Mitigation:

  • Implement checks to validate session IDs against known valid users and deny unauthorized access.

2. Session Assign

Vulnerabilities:

Cookie Created Without the HttpOnly Flag

Approach:

  • Inspect cookies via developer tools or proxy tools to check for the HttpOnly flag.
  • Attempt to steal cookies using XSS vulnerabilities if the flag is missing.

Mitigation:

  • Always set the HttpOnly flag on cookies to prevent client-side scripts from accessing them.

Cookie Created Without Secure Flag (SSL)

Approach:

  • Check cookies using browser developer tools to see if the Secure flag is set.
  • Monitor traffic using a tool like Wireshark to see if cookies are sent over unencrypted HTTP.

Mitigation:

  • Ensure the Secure flag is set on cookies, allowing them to be transmitted only over HTTPS.

3. Session Exchange

Vulnerabilities:

Session ID Contained in URL

Approach:

  • Check application URLs for session IDs and see if they are exposed in links.
  • Attempt to use captured session IDs from the URL in another session.

Mitigation:

  • Avoid including session IDs in URLs. Instead, use cookies for session management.

Multiple Sessions Allowed

Approach:

  • Log in from multiple devices/browsers using the same credentials.
  • Test if multiple active sessions can be maintained concurrently.

Mitigation:

  • Implement a single-session policy to restrict multiple concurrent sessions for the same user account.

IP Hopping

Approach:

  • Log in from one IP address, then attempt to access the session from a different IP.
  • Observe if the session remains valid across IP changes.

Mitigation:

  • Implement IP address validation or prompt for re-authentication when the IP address changes.

Kiosk Issue

Approach:

  • If the application is designed for kiosks, check if sessions persist when switching users on the same device.
  • Attempt to access a previous user’s session after they log out.

Mitigation:

  • Ensure sessions are cleared upon logout, especially in shared environments.

4. Session Termination

Vulnerabilities:

No Logout Button

Approach:

  • Check the application for a logout button or function.
  • If absent, test how sessions terminate (e.g., through browser closure).

Mitigation:

  • Implement a clear and accessible logout button that invalidates the session.

Session Expiration Issue

Approach:

  • Log in and leave the session idle to see if it expires after a reasonable time.
  • Check for an active session after an extended period of inactivity.

Mitigation:

  • Implement session expiration policies to automatically log out users after inactivity.

Session Not Expired on Logout

Approach:

  • Log in, then manually log out and attempt to use the session again with the old session ID.
  • Check if the session is still valid post-logout.

Mitigation:

  • Invalidate the session ID upon logout to prevent reuse.

Session Timeout

Approach:

  • Test the session timeout settings by logging in and leaving the session inactive.
  • Check if the session can be prolonged through active requests just before expiration.

Mitigation:

  • Set appropriate session timeout durations and actively enforce them on the server-side.

Summary

  • Testing: Use proxy tools, browser developer tools, and sniffing tools to gather information about session management and identify vulnerabilities.
  • Documentation: Keep detailed notes on the vulnerabilities discovered, including steps to reproduce, potential impacts, and recommended mitigations.
  • Reporting: Create a structured report that outlines findings and provides actionable remediation steps.

--

--

Ajay Monga
Ajay Monga

Written by Ajay Monga

Sharing thoughts on the latest trends in Business and Technology

No responses yet