Cybersecurity Glossary

What is Session Hijacking?

Session hijacking is unauthorized use of an existing user session. Instead of knowing the password, the attacker presents a valid session cookie or access token, making requests appear to come from the victim. Administrator and support sessions are particularly valuable.

How are sessions obtained?

SourceExampleMain control
BrowserXSS reads a cookie without HttpOnly or performs actions inside the browser.Fix XSS, add HttpOnly and CSP.
TransportToken leaks over HTTP, through a proxy, URL or log.Enforce TLS and keep tokens out of URLs/logs.
EndpointInfostealer copies browser profiles and cookies.Endpoint controls, short sessions and reauthentication.
ApplicationPredictable IDs, fixation or disclosure in errors.Random IDs, regeneration and safe error handling.

Example secure session cookie

Set-Cookie: session=RANDOM_OPAQUE_VALUE;
  Path=/;
  Secure;
  HttpOnly;
  SameSite=Lax

Secure restricts transport to HTTPS, HttpOnly blocks direct JavaScript access and SameSite limits cross-site requests. None makes a stolen token useless; the server must enforce lifetime, revocation and trust transitions.

Limiting the impact

  • - Regenerate IDs after login, MFA and privilege changes.
  • - Use short idle and reasonable absolute timeouts.
  • - Require reauthentication for password, payment and administrative actions.
  • - Revoke all relevant sessions on logout, password change and incident response.
  • - Detect new devices, impossible travel and parallel use without relying on brittle IP pinning.
  • - Never record token values in analytics, referrers, URLs or normal logs.

Detection and response

Signals include abrupt device or region changes, incompatible concurrent use, new sensitive actions and reuse of revoked tokens. A response can suspend the session, notify the user and require authentication. Combine signals because VPN, mobile and travel changes can look similar.

Useful open-source tools

OWASP ZAP shows cookie attributes, token flows and logout behavior. mitmproxySemgrep can enforce project-specific cookie and logging rules. Use only owned test accounts and explicit authorization.

Penetration Tests

Uncover Security Vulnerabilities

Professional penetration testing for your business

Web Apps
Networks
Mobile Apps
10% New Customer Discount
Plan Now

Thank you for your feedback! We will review it and optimize this content.

Do you have feedback on Session Hijacking? Tell us!