Skip to main content
Blog
Blog Attacks

Cookie Theft and Session Hijacking: How Attackers Steal Sessions and How to Stop Them

Cookie theft is when an attacker captures a session token from a logged-in user and replays it to impersonate them. No password needed, no MFA prompt. Here is how the attack works and how to stop it.

Jul 21, 2026 9 min read
Cookie Theft and Session Hijacking: How Attackers Steal Sessions and How to Stop Them
Table of Contents

TL;DR: post-authentication session token replay across devices

  • The gap: Every pitch deck treats MFA as the finish line. Cookie theft calls the bluff. MFA authenticates the login event, and a stolen session cookie is the receipt that proves login already happened, so the server hands over the account with no second prompt.
  • The evidence: SpyCloud recaptured over 17 billion stolen credential records from the criminal underground in 2024, and DBSC only covers Chrome 146+ on Windows. cside fingerprints devices across 250+ signals at 99.7% accuracy to catch the moment a cookie is replayed from the wrong machine.
  • The decision: Any team relying on MFA plus HttpOnly to guard live sessions is exposed. Add runtime script monitoring for token exfiltration and device-level behavioral scoring this quarter, before an infostealer sale on Telegram becomes your incident.

Short on time? See cside's account-takeover detection. It covers everything below in one deployment.

Cookie theft is when an attacker captures the session token a website issued after a user logged in and replays it from a different device. The attacker inherits the user's access without knowing their password. No MFA prompt fires. The user stays logged in and notices nothing; both sessions run in parallel.

The reason MFA does not stop this is structural. MFA authenticates the user at the login event. After login, the server relies on the session cookie, a time-limited credential that proves the browser already passed authentication. A stolen cookie is proof the browser already passed. The server cannot tell the difference between the real user and the attacker unless it checks something beyond the token itself.

Security researchers call this a pass-the-cookie attack. It is the dominant technique behind a large share of account takeovers in 2026.

How session hijacking works

The attack chain is the same regardless of how the cookie was obtained.

  1. The user authenticates. The browser completes login and MFA. The server issues a session cookie, a long random string, and sends it back with the response.
  2. The attacker captures the cookie. This happens through infostealer malware, a phishing proxy, or a malicious script running in the page.
  3. The attacker replays the cookie. From their own browser or a script, they set the stolen cookie and send a request to the target site.
  4. The server sees a valid session. The cookie is active and was issued to an authenticated user. Access is granted.

The legitimate session remains open. The user is still browsing on their device; the attacker is browsing the same account on theirs.

Three ways attackers steal session tokens

Infostealer malware

Infostealer malware is the most common route. Families like Lumma, Vidar, and RedLine sweep the browser's on-disk cookie store, extract session tokens for hundreds of sites, and transmit them to an attacker-controlled server within minutes of infection. SpyCloud's 2025 Annual Identity Exposure Report recaptured over 17 billion stolen credential records from the criminal underground in 2024. Stolen session cookies reach Telegram markets within hours of a successful infection.

The browser's cookie store is a local file, plaintext or a local SQLite database. Any process running with the user's privileges can read it. Infostealers do not intercept network traffic; they read from disk after the browser has already decrypted the data.

Adversary-in-the-middle (AiTM) phishing

AiTM phishing places a reverse proxy between the victim and the real login page. The victim sees an exact visual copy of the login, enters credentials, and completes MFA. The proxy forwards everything to the real site and captures the resulting session cookie on its way back. The attacker now holds a valid post-authentication token without having passed MFA themselves.

This technique defeats traditional anti-phishing controls because the page looks authentic, the MFA prompt completes against the real service, and the victim logs in normally. Only the attacker's proxy sits in the middle, invisible.

Malicious third-party scripts and XSS

An XSS vulnerability or a compromised third-party script can extract session tokens from the browser at runtime. JavaScript running in the page's origin context can read cookies not flagged HttpOnly, encode them, and exfiltrate them in requests that look like routine analytics calls.

This is the client-side supply-chain vector: the attacker does not target your site directly but compromises an analytics tag, chat widget, or payment library that your site trusts and loads on every page. The skimmer arrives inside code the site already considers safe.

Why standard defenses miss this

The HttpOnly flag

HttpOnly prevents JavaScript from reading the cookie via document.cookie. It blocks XSS token reads for that specific cookie, which matters. But it does nothing against infostealer malware that reads the cookie directly from disk after the browser has stored it, and it does not protect against an AiTM proxy capturing the token over the network before it reaches the protected store.

HTTPS and TLS

TLS encrypts traffic in transit and stops passive network sniffing. Infostealers read from disk, after decryption. AiTM proxies terminate TLS on both sides of the connection. Neither is stopped by transport encryption alone.

MFA

MFA verifies the user at login. After login, the server relies on the cookie alone. A stolen cookie never triggers another MFA prompt unless the server forces re-authentication based on device or behavioral signals, which most servers do not do on every request.

Device-bound sessions and DBSC

The structural fix for pass-the-cookie attacks is binding the session to the hardware that created it. A stolen cookie becomes useless if the server requires cryptographic proof that the browser still controls a specific device-held private key.

Google's Device Bound Session Credentials (DBSC) protocol does this using the device's TPM or Secure Enclave. On Chrome 146+ for Windows, the browser generates a private key in hardware during session establishment. Short-lived session cookies are issued only as long as the browser can prove possession of that key. An attacker who steals the cookie from another device cannot refresh it without the private key.

DBSC is a meaningful advance against replay attacks. The practical limits as of mid-2026:

  • Coverage: Chrome 146+ on Windows is the primary deployment. iOS, Firefox, and Safari do not yet support DBSC.
  • Fallback paths: when no TPM is present or a network error occurs during key verification, DBSC may skip binding. That session then behaves like a conventional cookie.
  • On-device malware: if an infostealer runs on the same machine holding the private key, the attacker can use the session from that device. DBSC addresses off-device replay, not same-device compromise.

These gaps mean DBSC is one layer, not a complete solution.

Session hijacking prevention: a layered checklist

ControlWhat it stops
TLS + HSTSNetwork sniffing (session sidejacking)
HttpOnly, Secure, SameSite flagsXSS reads via document.cookie
Session ID rotation after loginSession fixation
Short absolute and idle timeoutsWindow for replay after theft
Long random session tokensToken guessing
Server-side revocation on logoutActive sessions after account action
DBSC (Chrome 146+ / Windows)Off-device replay of stolen cookie
Client-side script monitoringToken exfiltration via XSS or supply chain
Device intelligence + behavioral scoringReplayed token reaching the live session

No single control is complete. Infostealers defeat transport controls. AiTM proxies defeat MFA and HTTPS at the session layer. HttpOnly limits one JavaScript read vector but not disk reads. The layered model works because each control defeats what the others miss.

Detecting a hijacked session in the live browser

Prevention reduces the probability of token theft. Detection catches the session that was already stolen and is being replayed.

cside runs as a single first-party JavaScript snippet in the visitor's browser with no proxy and no DNS changes. It monitors what third-party scripts and the session itself actually do on the live page for real users, not what a crawler or scanner observes at code rest.

Token exfiltration at the source. A third-party script that attaches unexpected event listeners to form fields, reads cookie values outside normal analytics calls, or sends data to an unknown domain fires a detection signal before the token leaves the page. This closes the XSS and supply-chain vector before a cookie is stolen in the first place. The same runtime monitoring also catches affiliate cookie stuffing and link hijacking, where injected scripts drop attacker-controlled affiliate cookies or rewrite outbound links to redirect attribution, a distinct but equally invisible browser-layer attack.

Device mismatch on replay. When a stolen cookie is used from a different device, the session's fingerprint changes. cside's device intelligence builds a persistent device ID from 250+ browser, hardware, and network signals at 99.7% accuracy. A fingerprint mismatch after an established session is an anomaly the behavioral scoring layer flags for re-authentication or block.

Behavioral signals. Automated session replay from a script or an AI agent produces patterns that differ from real human sessions: no realistic mouse movement, no scroll variance, no natural typing cadence. cside's behavior-level signals separate automation from genuine use.

cside also integrates AI agent detection, catching orchestration tools and automated browsers that replay stolen sessions or run scripted account access at scale.

PCI DSS 4.0.1 and session security on payment pages

For e-commerce and payment platforms, the client-side script and XSS vectors that exfiltrate session tokens are the same risks PCI DSS 4.0.1 requirements 6.4.3 and 11.6.1 target. Requirement 6.4.3 mandates a script inventory and authorization method for every script on payment pages. Requirement 11.6.1 requires continuous monitoring and alerting on unauthorized changes to payment-page scripts and HTTP security headers.

A malicious third-party script exfiltrating a session token or payment card data on a checkout page is precisely the threat those requirements address. cside automates both controls and produces QSA-ready weekly reports (VikingCloud-validated). Monitoring that catches a rogue script stealing session tokens also satisfies the tamper-detection mandate QSAs now assess.

PCI DSS 4.0.1 requirements 6.4.3 and 11.6.1 are mandatory and have been assessed since 1 April 2025.

Simon Wijckmans
Founder & CEO

Founder and CEO of cside. Previously a product manager on Cloudflare Page Shield (now Cloudflare Client-Side Security). Co-chair of the W3C Anti-Fraud Community Group and a Forbes 30 Under 30 honoree. Building accessible security against client-side attacks, web security is not an enterprise-only problem.

FAQ

Frequently Asked Questions

Cookie theft is when an attacker captures the session cookie (or session token) a website issued to a logged-in user and replays it from a different device to impersonate that user. Because the cookie represents an already-authenticated session, the attacker inherits the user's access without knowing their password or facing an MFA prompt.

A pass-the-cookie attack is the act of stealing a session cookie and using it on another device to take over the live session. Authentication already completed when the original session was created, so the server sees a valid cookie and grants access without prompting for credentials again. MFA protects the login event, not the live session after it.

Yes. Session hijacking works after authentication completes. Whether an attacker uses infostealer malware to copy cookies from the browser, runs an adversary-in-the-middle phishing proxy, or exfiltrates a token via a malicious third-party script, the stolen cookie represents a session that already passed MFA. The server cannot distinguish a replay from the legitimate user without device binding or behavioral anomaly detection.

Session hijacking steals an existing, active session token. Session spoofing creates or guesses a session ID to impersonate a user without stealing a real token. Session fixation forces a known session ID on the victim before they authenticate, then takes over that session when they log in. All three exploit session identifiers but at different points in the lifecycle.

A device-bound session ties a session token cryptographically to the specific hardware that created it. Google's Device Bound Session Credentials (DBSC) protocol, rolling out in Chrome 146+ on Windows, uses a private key held in the device's TPM or Secure Enclave. The server verifies possession of that key to refresh short-lived session cookies. A stolen cookie becomes useless on another machine because it cannot prove possession of the private key.

DBSC reduces but does not eliminate cookie theft risk. Documented fallback paths exist when no TPM is present or when network errors occur during key verification, meaning binding can be skipped. Behavioral and device-intelligence detection provides the complementary layer that catches replayed sessions in those gaps.

Prevention uses layers: enforce TLS and HSTS; set HttpOnly, Secure, and SameSite flags on session cookies; rotate the session ID immediately after login; apply short absolute and idle timeouts; use long random tokens with server-side revocation. Add device binding via DBSC or device-intelligence signals to tie sessions to hardware where possible. Monitor every third-party script for token exfiltration behavior and score each session against device and behavioral baselines to trigger re-authentication on anomalies.

cside runs as a single first-party JavaScript snippet with no proxy and no DNS changes. It monitors what third-party scripts and the session itself actually do in real visitors' browsers on the live page, not a crawler snapshot. Layered detection combines network-level, browser-level, and behavior-level signals (mouse movement, scroll, typing cadence) with AI-written-text detection on submitted form content to flag sessions whose device or behavior no longer matches the legitimate user.

Device intelligence at 99.7% accuracy across 250+ signals distinguishes a re-used or spoofed device from the real one. cside also catches the malicious third-party script or XSS injection that exfiltrates a session token in the first place, closing the client-side supply-chain vector at the source.

Monitor and Secure Your Third-Party Scripts

Gain full visibility and control over every script delivered to your users to enhance site security and performance.

Start free, or try Business with a 14-day trial.

cside dashboard interface showing script monitoring and security analytics
Related Articles
Book a demo

Want to walk through this with an engineer?

Thirty minutes, on your own site. Not a slide deck.

We'll show you:

Which third-party scripts are running on your site right now
Where you stand on PCI DSS 6.4.3 and 11.6.1
How much of your traffic is bots and AI agents

Rather just send a question?

Finding open slots…

Real humans only. We'd know.

Having trouble booking? Open scheduler in a new tab

What are you trying to solve?

Tell us in a line and we'll come back with something useful, not a generic pitch.

We usually help with:

Seeing which third-party scripts run on your site
PCI DSS 6.4.3 and 11.6.1 evidence
Bots, AI agents and account takeover

Prefer to just book a time? Pick a slot instead