The Novee Gym is open for business at Black Hat Europe

Book a meeting

The Novee Gym is open for business at Black Hat Europe

Book a meeting

Glossary › Session Hijacking

Session Hijacking

Explore Article +

Key Takeaways

  • Session hijacking means taking over a logged-in user’s session with a stolen token, which bypasses passwords and MFA entirely.
  • Session fixation plants a known session ID before the victim logs in.
  • Documented cases from Firesheep to the 2023 Okta breach trace back to an exposed or overly long-lived token.
  • Session hijacking prevention combines cookie flags, ID rotation and server-side session invalidation.

What Is Session Hijacking?

Session hijacking is an attack in which an adversary takes control of a valid user session by obtaining the token the application issued after login. Whoever presents that token is treated as the user, so it skips the password and MFA steps that already succeeded. When the token lives in a cookie, the attack is often called cookie hijacking or sidejacking.

The Methods Attackers Use to Steal Session Tokens

Cross-site scripting

Without the HttpOnly flag, an XSS payload can read the session cookie. Even with it, injected script can act inside the session, as Novee’s research into a stored XSS flaw leading to account takeover in pretalx shows.

Interception, malware and leaks

Tokens sent over plain HTTP can be sniffed on shared networks, and infostealer malware copies cookies from the browser. Tokens also leak through URLs, logs and HAR files, and app flaws such as UXSS in Android WebView can run attacker script in another site’s context.

How Session Fixation Differs From Session Hijacking

Classic hijacking steals a token after login. Session fixation reverses the order: the attacker sets a session ID and waits for the victim to authenticate with it. If the application keeps that ID after login, the attacker’s known value becomes an authenticated session. MITRE tracks this as CWE-384, and the fix is to issue a new session ID at login and every privilege change.

Real Session Hijacking Cases and What Made Each One Possible

Firesheep (2010)

Eric Butler released this Firefox extension at ToorCon in October 2010. Facebook and Twitter encrypted logins but sent session cookies over plain HTTP, so anyone on open Wi-Fi could capture and replay them. The failure: cookies were not confined to encrypted connections.

Linus Tech Tips (2023)

In March 2023, an employee opened malware disguised as a sponsorship PDF. It stole browser session tokens that attackers used to take over the company’s YouTube channels. The failure: sessions could be replayed from another machine, so the password and 2FA were never tested.

Okta support system (2023)

In October 2023, an attacker used a stolen service account credential to access Okta’s support system and downloaded customer HAR files containing session tokens. Okta said 134 customers were affected and five had sessions hijacked. The failure: unsanitized diagnostic files held live tokens.

How to Protect Session Tokens at the Application Level

  • Harden cookies: set Secure, HttpOnly and SameSite, per OWASP guidance.
  • Rotate IDs: generate random IDs with at least 64 bits of entropy and regenerate them at login.
  • Invalidate server-side: enforce idle and absolute timeouts, and destroy sessions on the server at logout.
  • Prevent leaks: keep tokens out of URLs and logs, and sanitize HAR files.

Novee’s continuous AI pentesting reasons about workflows and permissions like an attacker across web apps, APIs and mobile apps, catching the flaws that enable hijacking. Three independent agents validate each finding, and Agentic Remediation retests to confirm the fix.

FAQ

No. HTTPS stops attackers from sniffing tokens in transit, which defeats Firesheep-style attacks, but it does nothing against XSS, infostealer malware, leaked logs or HAR files, or session fixation. The cookie also needs the Secure flag, or one plaintext request can expose it.

Yes. Single-page applications often keep bearer tokens or JWTs in localStorage, where any script on the page, including an XSS payload, can read them. HttpOnly, Secure cookies reduce that exposure, but SPAs still need strong XSS defenses, short token lifetimes and server-side refresh token revocation.

Session hijacking is one route to account takeover. It gives the attacker the victim’s current session while the token stays valid. Account takeover is the broader outcome, where the attacker gains lasting control, often by using a hijacked session to change the email, password or MFA settings.

It can if logout only deletes the cookie in the browser. When the server does not destroy the session, a token the attacker already copied keeps working until it expires. Proper logout invalidates the session server-side, and absolute timeouts limit how long any stolen token remains usable.

No. HttpOnly prevents JavaScript from reading the cookie, which blocks the classic XSS cookie-theft payload. It does not stop sniffing when the Secure flag is missing, malware reading the browser’s cookie store, session fixation, or XSS that acts inside the victim’s session without extracting the token.