Password Password

Security, explained for the people who have to fix it.

Attack and Defense

Session tokens: what a stolen cookie can do, and what limits it

A stolen session cookie is a logged-in user. Why an idle timeout does not bound the thief, and what absolute timeouts, rotation and device binding change.

A password protected by a second factor is a hard target. The cookie your server hands out one second after that second factor succeeds is not: it is a single string that means "this request is that person", and anything holding it is that person until something takes it away. This article covers what that string is worth to an attacker, which parts of the problem the browser can enforce for you, why the timeout most applications configure does nothing about a thief, and how much the exposure actually shrinks when you add an absolute timeout, rotation, or device binding. It ships a script that audits the Set-Cookie headers from your own site offline and computes the exposure window for a policy you describe, plus the dataset behind the chart. It also reports which cookie flags the S&P 500 companies' homepages actually set, read on 15 November 2026.

The cookie is the account

MITRE ATT&CK catalogues the theft as T1539, Steal Web Session Cookie (version 1.5, last modified 12 May 2026), and the use as T1550.004, Web Session Cookie (version 2.0, same date). The first page states the premise plainly: "Web applications and services often use session cookies as an authentication token after a user has authenticated to a website." The second explains why this is worth an attacker's time even against accounts with multi-factor authentication: a session that already exists is already authenticated, so importing the cookie into a browser they control lets them act as the user without ever meeting the second factor. ATT&CK names adversary-in-the-middle phishing proxies, among them Evilginx2 and Muraena, as a route to collecting them, alongside malware that reads the browser's cookie storage.

The government view is the same. NIST and CISA published IR 8587 as an initial public draft in December 2025, "Protecting Tokens and Assertions from Forgery, Theft, and Misuse", with a comment period that closed on 30 January 2026. Its section 6.5 describes device-bound session credentials as technology "designed to help protect against cookies and session hijacking threats", aimed at the case where a session "has not shifted to a new, potentially compromised device or attacker who may have been able to compromise a session cookie or access token." The defensive question is therefore not whether the cookie can be taken, but how long it is worth anything once it has been.

What the browser will enforce for you

SP 800-63B-4, published in July 2025, gives seven requirements for cookies used for session maintenance in section 5.1. Cookies "SHALL be tagged to be accessible only on secure (i.e., HTTPS) sessions", "SHALL be accessible to the minimum practical hostnames and paths", "SHOULD be tagged as inaccessible via JavaScript (i.e., HttpOnly)", "SHOULD be tagged to expire at or soon after the session's validity period", "SHOULD have the __Host- prefix and set Path=/", "SHOULD set SameSite=Lax or SameSite=Strict", and "SHOULD contain only an opaque string (e.g., a session identifier) and SHALL NOT contain cleartext personal information." The session secret itself is "established using input from an approved random bit generator" and is "at least 64 bits in length"; OWASP's Session Management Cheat Sheet puts the same floor as "at least 16 hexadecimal characters long to achieve the required 64 bits of entropy."

The __Host- prefix is the item most often missing (none of the 823 cookies in our survey below uses it), and it is the one the browser polices. Section 4.1.3.2 of draft-ietf-httpbis-rfc6265bis-22, published 1 December 2025, defines it: "If a cookie's name begins with a case-sensitive match for the string __Host-, then the cookie will have been set with a Secure attribute, a Path attribute with a value of /, and no Domain attribute." That turns three conventions into a contract the user agent refuses to break, which matters because a Domain attribute widens the cookie to every subdomain: with Domain=site.example the agent sends it "to site.example, www.site.example, and www.corp.site.example", so any one of those hosts becomes a place your session can leak from.

Verify this from the headers rather than from the framework's documentation, because section 8.6 of the same draft points out that the server cannot tell afterwards: "A server cannot determine from the Cookie field alone when a cookie will expire, for which hosts the cookie is valid, for which paths the cookie is valid, or whether the cookie was set with the Secure or HttpOnly attributes." Capture your own response and read it:

curl -sSI https://your-own-site.example/ | grep -i '^set-cookie' > my-headers.txt
python session-tokens-stolen-cookie-flags-rotation.py --cookies my-headers.txt

Run against a deliberately mixed example, the audit prints the rule, the finding, and the document behind it:

SESSIONID (16-char value)
  [SHALL ] Secure missing
           cookies for session maintenance SHALL be accessible only on HTTPS sessions
  [SHOULD] SameSite not set
  [SHOULD] no __Host- prefix

__Host-sid (22-char value)
  meets every rule in this script

remember_me (26-char value)
  [REVIEW] persistent cookie
           persistent for 43,200 minutes (720.0 h); longer than the 24 h overall
           reauthentication timeout SP 800-63B-4 SHOULD apply at AAL2
  [SHALL ] value may carry cleartext personal information

Cookie flags in the wild: 498 company homepages, read 15 November 2026

The rules above say what a session cookie should carry. To see what large companies' web servers actually send, we requested the homepage of each S&P 500 company on 15 November 2026 and ran every Set-Cookie header that came back through the audit in this article's script.

  • Which sites. The same 498 company web domains as our SPF and DMARC survey: the companies in Wikipedia's "List of S&P 500 companies" (revision 1382178819), each with the website named in the infobox of its own article. We asked for https://<host>/ on the host the infobox gives and followed redirects one at a time. We did not look for login pages.
  • What we sent. One ordinary GET per page, between 13:55 and 13:59 UTC, with a user agent that names this site. Before the first request to any host we read its robots.txt, and we skipped every page the file refuses to our script, to all agents or to several named AI crawlers, and every host whose robots.txt we could not read. That left 101 sites (20.3%) unrequested: 88 whose robots.txt answered with an error or not at all, and 13 that refuse the page. We never sent a cookie back, did not read the pages themselves, and saved no cookie value: the saved copy keeps each cookie's name, its attributes and the length of its value. In all, 1,670 requests: 956 for robots.txt files and 714 for pages.
  • What came back. 378 homepages answered with a page after redirects, 17 answered with an error status (15 of them 403 Forbidden), 1 did not answer and 1 redirected in a loop. 258 sites set at least one cookie in a response header: 823 distinct cookies, counting each name once per site as a browser's cookie store does (1,060 Set-Cookie headers in all). The median site set 2, the most 30.
  • How it was counted. The survey script, cookie-flags-survey-sp500.py, re-reads the saved headers and applies this article's own audit, so every number below can be recomputed without contacting the sites again. The counts are in cookie-flags-survey-sp500.csv, one row per cookie family. We publish shares only and name no company.
What the Set-Cookie header carries Cookies (of 823) Share
Secure 643 78.1%
HttpOnly 399 48.5%
SameSite=Strict 21 2.6%
SameSite=Lax 62 7.5%
SameSite=None (every one also Secure) 304 36.9%
No SameSite attribute 436 53.0%
__Host- prefix 0 0.0%
__Secure- prefix 1 0.1%
A Domain attribute (sent to subdomains too) 460 55.9%
Persistent (Expires or Max-Age) 456 55.4%
Lifetime over 30 days 168 20.4%
Lifetime over 400 days 44 5.3%
Secure, HttpOnly and SameSite Lax or Strict together 39 4.7%

No cookie on any of the 258 sites uses the __Host- prefix, the prefix SP 800-63B-4 asks session cookies to carry and the one the browser enforces. 154 sites (59.7%) mark every cookie they set Secure, and 98 (38.0%) mark every one HttpOnly. More than half the cookies (436) carry no SameSite attribute at all and leave the choice to the browser. Not one cookie pairs SameSite=None with a missing Secure flag, the combination browsers reject. 44 cookies on 28 sites ask to live longer than 400 days; Section 5.5 of the cookie draft has user agents cut any lifetime to a limit that "SHOULD NOT be greater than 400 days", so those requests are cut short in the browser. The median persistent cookie asks for 1 day.

A homepage is not a login page, and most of these cookies are not sessions. We sorted them by name into the families their vendors and frameworks document (the name lists are in the script):

Family, by cookie name Sites Cookies Secure HttpOnly SameSite Lax or Strict __Host-
Bot management and CDN 162 283 79.2% 63.3% 6.0% 0
Load balancer and routing 84 141 76.6% 58.2% 1.4% 0
Server session ID 31 34 85.3% 82.4% 38.2% 0
Site, language or region 39 56 87.5% 35.7% 8.9% 0
Analytics and monitoring 15 23 82.6% 21.7% 17.4% 0
Consent 1 1 100.0% 0.0% 0.0% 0
Other or unrecognised 101 285 74.7% 29.8% 14.7% 0

The largest family is bot management: 283 cookies on 162 sites (62.8% of the sites that set any), followed by load-balancer stickiness on 84. Those are set by services that sit in front of the website, not by the website's own application.

The family that matters for this article is the server session ID: 34 cookies on 31 sites whose names are framework defaults for one (ASP.NET_SessionId on 14 sites, JSESSIONID on 6, and 9 other names). They were issued to an anonymous visitor who never signed in, so they show each framework's defaults rather than anyone's login settings. 29 are Secure and 28 HttpOnly; 13 say SameSite=Lax, 13 SameSite=None and 8 nothing, and none says Strict. 10 of the 34 carry Secure, HttpOnly and Lax or Strict together, 2 widen themselves with a Domain attribute, 3 are persistent, and none uses the __Host- prefix.

What this does not show:

  • Login sessions. We fetched public homepages only. A company's sign-in service may set a different, stricter cookie; this survey cannot see it.
  • Cookies set by scripts. Analytics and consent tools often set their cookies from JavaScript after the page loads. Those never appear in a Set-Cookie header, which is why those families are small here, and a cookie written by a script cannot be HttpOnly.
  • The 101 sites we did not request. 88 of them answered our robots.txt request with an error status or not at all, and we left them alone. They are not a random sample of the list, so read every share as describing the sites that answered.
  • One day, one client. Responses can differ by country, by user agent and from one hour to the next. These are the headers our script received from one location on 15 November 2026.

The point for your own site is the gap between what the rules ask for and what ships by default. Capture your own headers, run the audit above, and set the flags yourself rather than trusting the framework or the service in front of it.

The timeout that does nothing

Most applications configure an idle timeout and stop there. OWASP states the flaw in one sentence: "if the attacker is able to hijack a given session, the idle timeout does not limit the attacker's actions, as they can generate activity on the session periodically to keep the session active for longer periods of time." An idle timeout measures whether someone is using the session, and the thief is someone. What bounds them is the absolute timeout, which OWASP describes as limiting "the amount of time an attacker can use a hijacked session and impersonate the victim user."

SP 800-63B-4 sets that ceiling by assurance level in section 5.2. At AAL1, "a definite reauthentication overall timeout SHALL be established, which SHOULD be no more than 30 days", and an inactivity timeout "MAY be applied but is not required". At AAL2 the overall timeout "SHOULD be no more than 24 hours" and the inactivity timeout "SHOULD be no more than 1 hour". At AAL3 "the overall timeout for reauthentication SHALL be no more than 12 hours", with an inactivity timeout that "SHOULD be no more than 15 minutes".

The window, computed

The script's second mode turns a policy into the longest window in which a stolen cookie still works. The model is deliberately simple: an inactivity timeout never counts as a bound, and the window is the smallest of the controls that do bound it, which are the overall reauthentication timeout, rotation with replay detection (bounded by how soon the real user comes back and collides with the rotated token), an out-of-band alert acted on, and a device-bound short-lived cookie. With nothing at all, the bound is the cookie's own Max-Age.

Bar chart of how long a stolen session cookie stays usable under eight policies, from 30 days down to 10 minutes
Upper bounds computed by the script shipped with this article, from the timeout values in SP 800-63B-4 Sec. 5.2, the OWASP cheat sheet, and a 10-minute device-bound refresh cookie.
Policy Usable window Bounded by
Idle timeout only, 30-day persistent cookie 43,200 min the cookie's Max-Age
AAL1 overall timeout 43,200 min reauthentication timeout
AAL2 overall timeout, 1 h inactivity 1,440 min reauthentication timeout
AAL3 overall timeout, 15 min inactivity 720 min reauthentication timeout
Office-day absolute timeout 480 min reauthentication timeout
AAL2 plus rotation with replay detection, user back within 1 h 60 min rotation
AAL2 plus an alert acted on within 30 min 30 min detection and revocation
Device-bound session, 10-minute refresh cookie 10 min device-bound cookie lifetime

The spread between the widest and narrowest configuration is 4,320 times. Two things stand out. The AAL1 ceiling and a 30-day persistent cookie are the same number, so a policy written to AAL1 and no policy at all end in the same place. And the controls that get the window under an hour are not timeouts at all: they are rotation that detects a duplicate, an alert someone acts on, and binding.

Rotation, and what makes it bite

Regenerating the session ID is mandatory in one place regardless of the rest: OWASP requires it "after any privilege level change within the associated user session", above all at login, which is what prevents session fixation. Rotation on a timer is a different control, and on its own it does not help, because a thief who is using the session receives each new token as it is issued.

What makes rotation bite is replay detection. RFC 9700, the OAuth 2.0 security best current practice published in January 2025, requires that "refresh tokens for public clients MUST be sender-constrained or use refresh token rotation", and its refresh-token protection section treats the reuse of an already-rotated token as evidence of compromise, with the response being revocation of the whole family of tokens issued from that grant. Applied to sessions, the rule is: when a superseded session token arrives, do not silently reissue, end every session in that lineage and make the user authenticate again. That is what turns the victim's next ordinary page load into the end of the attacker's access, and it is the mechanism behind the 60-minute row in the table.

The other half of RFC 9700's sentence is sender-constraining, for which it points at mutual TLS and at RFC 9449, DPoP, published in September 2023. Its abstract: "This document describes a mechanism for sender-constraining OAuth 2.0 tokens via a proof-of-possession mechanism on the application level. This mechanism allows for the detection of replay attacks with access and refresh tokens."

Binding the session to a device

The browser-side version of the same idea is Device Bound Session Credentials. The W3C explainer states the goal as reducing "session theft by offering an alternative to long-lived cookie bearer tokens, that allows session authentication that is bound to the user's device": a key pair is created at sign-in, the server issues short-lived cookies, and the browser refreshes them by proving possession of the private key. Google's Chrome for Developers post, last updated 3 March 2026, says DBSC is available in Chrome 145 on Windows, that "Chrome on Windows protects these keys in hardware using the Trusted Platform Module (TPM)", and describes the outcome for a defender: "if an attacker is trying to use a stolen cookie on a different device without access to the TPM, you can deny the request."

SP 800-63B-4 already accommodates this in section 5.1, noting that such technologies "mitigate the risk of theft of session secrets by using cryptographic protocols that prove the possession of a session secret rather than using them as bearer tokens", and that session secrets used with proof of possession "MAY persist": the one case where a long-lived session is the safer design rather than the lazier one.

What none of it stops

  • The attacker who stays. The DBSC explainer is explicit that an attacker with ongoing access to a compromised user agent "will be able to continuously access fresh DBSC-controlled bearer tokens", and that sophisticated malware may use the secure element as a signing oracle. Binding converts an exfiltrated cookie into a local-presence requirement; it does not evict anyone.
  • Use of the victim's own browser. ATT&CK T1185, Browser Session Hijacking (version 2.1), describes injecting into the browser to inherit its cookies and sessions or proxying traffic through it, which ATT&CK notes can also defeat the protection two-factor authentication provides. Device binding, IP checks and user-agent checks all see the legitimate device, because it is the legitimate device.
  • Client-side timeouts. OWASP: "Session timeout management and expiration must be enforced server-side."
  • Property binding as a guarantee. Binding a session to IP address or user agent aids detection, but OWASP is candid that a shared NAT, a corporate proxy or a copied user-agent string defeats it, and that these properties "cannot be used by web applications to trustingly defend against session attacks".
  • The model itself. Every number in the table is an upper bound from arithmetic on a policy, not a measurement of an incident. Real detection times vary, and a user who does not return for a day does not trigger the rotation collision that day.

Detection is the part that survives all of this. ATT&CK's mitigation M1047 for T1539 asks you to "implement auditing for authentication activities and user logins to detect the use of stolen session cookies" and to "monitor for impossible travel scenarios"; its T1550.004 analytics look for session cookie reuse on unmanaged browsers and unfamiliar device fingerprints. Section 5.3 of SP 800-63B-4 is titled Session Monitoring for the same reason.

The dataset

_README for session-tokens-stolen-cookie-flags-rotation.csv, one row per modelled policy:

  • scenario: the policy described in words
  • absolute_minutes, idle_minutes: the overall reauthentication timeout and the inactivity timeout, in minutes; empty where the policy has none
  • rotation_minutes, victim_return_minutes: the rotation interval and the assumed time until the real user's next request
  • detection_minutes: assumed time from theft to an alert being acted on
  • binding, cookie_ttl_minutes: device where the session is bound to a device key, and the refresh cookie's lifetime
  • bounding_control: which control produced the window
  • usable_minutes, usable_hours: the computed upper bound
  • source_tag, generated_at: the document the timeout values came from, and the date the row was produced (2026-09-16)

cookie-flags-survey-sp500.csv, one row per cookie family plus one for all cookies: group, sites (sites that set at least one cookie of the family), cookies, then for each attribute its count and its share of the row's cookies (secure, httponly, samesite_strict, samesite_lax, samesite_none, samesite_absent, none_without_secure, host_prefix, secure_prefix, domain_attr, persistent, over_30_days, over_400_days, all_three for Secure plus HttpOnly plus SameSite Lax or Strict, no_shall_finding for cookies with no SHALL finding from the audit), and retrieved (2026-11-15).

What to do this week

  1. Capture your own Set-Cookie headers and run the audit; fix Secure, HttpOnly, SameSite and the __Host- prefix before anything else, because they cost a deploy and no design work.
  2. Find the absolute timeout in your session configuration. If there is not one, that is the finding, and 24 hours is the number SP 800-63B-4 points at for an AAL2 service.
  3. Make a superseded session token revoke its lineage instead of quietly issuing a new one, and alert on it.
  4. Give users a page that lists active sessions with device and location, and a control that ends all of them.
  5. Treat an authenticated session appearing from a new device or an impossible location as an alert to work, not a report to file.

The password was never the last line; the cookie is. Everything above decides how many minutes a copy of it is worth.

Update, 15 November 2026: added "Cookie flags in the wild": the cookie attributes the S&P 500 companies' homepages set, read on 15 November 2026, with the survey script and the aggregate counts. The rest of the article is unchanged, apart from one sentence in the introduction and one in the section on what the browser enforces.

Everything on this site is written for defenders and for people securing systems they own or are authorised to test. It describes how attacks work so they can be recognised and closed; it is not a guide to accessing anyone else's systems.

Sources

  1. NIST, SP 800-63B-4 "Digital Identity Guidelines: Authentication and Authenticator Management", Sec. 5 Session (read 2026-09-16)
  2. NIST, publication record for SP 800-63B-4 (published July 2025; supersedes SP 800-63B of 03/02/2020)
  3. OWASP, "Session Management Cheat Sheet" (source file last changed 13 August 2026, "docs: qualify SameSite cookie guidance"; read 2026-09-16)
  4. MITRE ATT&CK, "T1539 Steal Web Session Cookie" (v1.5, last modified 12 May 2026)
  5. MITRE ATT&CK, "T1550.004 Use Alternate Authentication Material: Web Session Cookie" (v2.0, last modified 12 May 2026)
  6. MITRE ATT&CK, "T1185 Browser Session Hijacking" (v2.1, last modified 12 May 2026)
  7. IETF, draft-ietf-httpbis-rfc6265bis-22 "Cookies: HTTP State Management Mechanism" (1 December 2025)
  8. Wikipedia, "List of S&P 500 companies" (revision 1382178819, read 2026-11-04; the company list for the cookie survey; each company's website from its own article's infobox, read the same day)
  9. IETF, RFC 9700 "Best Current Practice for OAuth 2.0 Security" (January 2025), Sec. 2.2.2 and 4.14
  10. IETF, RFC 9449 "OAuth 2.0 Demonstrating Proof of Possession (DPoP)" (September 2023)
  11. Google, "Device Bound Session Credentials now available on Windows", Chrome for Developers (last updated 3 March 2026)
  12. W3C Web Application Security WG, "Device Bound Session Credentials: A Protocol for Protecting From Cookie Theft" explainer (read 2026-09-16)
  13. NIST and CISA, IR 8587 ipd "Protecting Tokens and Assertions from Forgery, Theft, and Misuse" (initial public draft, December 2025), Sec. 6.5