DedSec Security Research ·
Here is a hypothetical. A dynamic scan of a web application that runs on HTTPS returns six results about its session handling.
The first, rated medium, is "Session cookie without HttpOnly flag" on sid. The second, rated low, is "Cookie without Secure flag", on the same cookie. The third, rated high, is "Session fixation: session identifier not renewed after login": the scanner captured sid on the login page, logged in, and saw the same value afterwards. The fourth is informational, "Session identifier renewed after login", on a second application the team also owns, and is recorded as a pass. The fifth is also a pass: "Logout invalidates session", because the logout response sent Set-Cookie: sid=; Max-Age=0. The sixth, rated medium, is "Session token has low entropy", from twenty tokens collected during the crawl.
Every one of those decisions rests on a header the scanner read, not on what the header proves. In our lab, built to reproduce the six shapes, the "not renewed" cookie never changed because authentication rode on a second cookie issued at login, and replaying the pre-login cookie jar got nobody's account in any trial. The "renewed" application issued a new identifier at login and left the old one authenticated, so a value planted before login opened the victim's account every time. The logout that cleared the cookie belonged to an application whose session lived entirely in a signed cookie, and the cleared value, replayed afterwards, was still the victim. And the "low entropy" token came from a cryptographically secure generator: twenty samples cannot show more than about 4.3 bits per character, so a 256-bit token measured as 173 bits, while tokens that were an MD5 hash of a counter, or the output of Python's Mersenne Twister, scored exactly as well as the real thing, and 156 Mersenne Twister tokens were enough to predict the next 1,000 exactly.
This post is for whoever is holding a session-management finding from a dynamic scan, or a clean result they are about to rely on. It covers:
It belongs to our series on confirming DAST findings; the series guide sets out the evidence classes the series uses. Several neighbours carry parts of this topic, and this post links to them rather than repeating them. SameSite and what it does to cross-site requests is measured in the CSRF post; a credentialed cross-origin read is the CORS post; bearer tokens that are not cookies at all are the JWT post; guessing a password rather than a session is the login rate-limit post; delegated login is the OAuth post; and sibling subdomains defeating SameSite for a socket are in the WebSocket post. A scanner that logs itself out, and therefore tests the rest of the application as an anonymous user, is the crawler-coverage post.
How we tested. Everything ran on 26 November 2026 on a virtual machine with two vCPUs, Ubuntu 24.04.4 and kernel 6.8.0, as an unprivileged user, with every server bound to 127.0.0.1 and nothing installed. The application was one server in Python 3.12.3's standard library, listening for HTTPS with a self-signed certificate and for plain HTTP on a second port, the second standing in for a plain-HTTP listener on the same host or a response a network attacker injects. The two browser builds ran at the same time against two copies of the server, one on ports 8443 and 8080 and one on 9443 and 9080. The browser mapped two names to 127.0.0.1 with a host-resolver rule, and nothing else resolved: app.lab.test is the application and evil.lab.test is a sibling subdomain an attacker controls.
The browsers were the two builds the WebSocket post used: Google Chrome for Testing 153.0.8010.12 and Chromium 156.0.8078.79, the binary from the chromium snap, run directly. Both ran headless, driven by Playwright 1.62.1, already on the machine. Every browser cell ran five times in each build, a fresh browser profile per attempt, so a cell is ten attempts: 600 browser attempts in all. Server-side behaviour was tested the way a scanner can test it, with a raw HTTPS client in Python that reads Set-Cookie and replays values by hand; each of its cells ran five times. Session-ID statistics ran offline on tokens from six generators, five samples at each size. A first run stopped partway through the fixation experiment because our driver waited for the wrong URL form after login; every result below is from the second, complete run.
The application is ours, written to be wrong in specific ways, one variant per behaviour: session before login or not, rotation at login, acceptance of identifiers it did not issue, logout and password-change handling, timeouts, and whether it reads the first or last of two same-name cookies. Idle and absolute timeouts were 3 and 8 seconds so they could be observed. This is not a measurement of any framework, browser beyond the two builds named, or scanner, ours included. RFC 6265, draft-ietf-httpbis-rfc6265bis-22, the OWASP Session Management Cheat Sheet, the OWASP Web Security Testing Guide's session chapter, MDN's Set-Cookie reference, CWE-384, CWE-613, CWE-614, CWE-1004 and their related entries, PortSwigger's Burp Sequencer documentation and Python's random documentation were fetched on 26 November 2026, and every quotation below was checked against those copies.
A note on the standards. RFC 6265 (2011) is still the published cookie RFC. Its revision, draft-ietf-httpbis-rfc6265bis, is the document that specifies SameSite, the cookie prefixes, the 400-day lifetime cap and the rule that plain HTTP cannot overwrite a Secure cookie. On 26 November 2026 the IETF datatracker listed draft 22 (1 December 2025) in the RFC Editor queue, intended as a Proposed Standard, but not yet published as an RFC. We cite it as a draft. And in October 2026 CWE version 5.0 deprecated CWE-613, "Insufficient Session Expiration", because it "was insufficiently clear", and split it: CWE-1463 "Insufficient Session Timeout Value", CWE-1464 "Improper Session Invalidation", and its children CWE-1465 (after user logout) and CWE-1466 (after an authentication credential change). The CWE entry now marks CWE-613's usage as prohibited for mapping. Many tools and reports still say CWE-613; CWE now points to CWE-1462, "Improper Session Management", and its descendants, which include CWE-1463 to CWE-1466 and also session fixation, CWE-384.
A session is a value the server handed to one browser, which the browser hands back on every request, and which the server treats as proof of who is asking. Every session finding is about one of three questions: who else can learn the value, who else can choose it, and how long it keeps working.
| Finding | What the scanner observed | What it has to establish |
|---|---|---|
| Cookie without HttpOnly (CWE-1004) | A Set-Cookie line without the attribute | That script running in your origin can read the session, and that such script can be made to run |
| Cookie without Secure (CWE-614) | A Set-Cookie line without the attribute | That the browser will send the session over plain HTTP to this host, and that something will make it do so |
| Broad Domain, or Path scope | Domain= on the parent, or a narrow Path | Which other hosts or paths receive or can overwrite the cookie, and who controls them |
| Persistent session cookie | Expires or Max-Age | How long the value works on the server, which the cookie attribute does not say |
| Session fixation (CWE-384) | The same value before and after login | That a value the attacker knows, planted before login, is authenticated after the victim logs in |
| No logout invalidation (CWE-1465) | Usually nothing, or a cleared cookie | That the old value, replayed after logout, still works |
| No invalidation after password change (CWE-1466) | Usually nothing | That another session's value still works after the change |
| Excessive or missing timeout (CWE-1463) | A long Max-Age, or nothing | That a replayed value works after the idle or absolute period, measured on the server |
| Low session-ID entropy (CWE-331, CWE-330, CWE-338) | Statistics over a sample of tokens | That an attacker can guess or predict a live value |
Two things follow from the table. First, every attribute finding is a statement about the Set-Cookie line, and what it enables depends on something else being true: an injection, a plain-HTTP request, a hostile sibling. Second, every server-side finding is invisible in the response. A logout that destroys the session and a logout that only clears the cookie send the same header; in our lab every variant's logout sent the same status, Set-Cookie line and body. The only evidence is the replay.
The first experiment sets one session cookie, sid=v1, from https://app.lab.test with different attributes, then looks at it from five places: script on the application's page, a same-origin fetch, a plain-HTTP request to the same host on the other port, the sibling evil.lab.test, and a page on another path of the application. Each cell is a count of the ten attempts, five per build, in which the cookie was readable or sent.
Set-Cookie | document.cookie on the app | Same-origin fetch | Plain HTTP, same host, other port | Sibling evil.lab.test |
|---|---|---|---|---|
sid=v1; Path=/ | 10 | 10 | 10 | 0 |
... ; HttpOnly | 0 | 10 | 10 | 0 |
... ; Secure | 10 | 10 | 0 | 0 |
... ; Secure; HttpOnly; SameSite=Lax | 0 | 10 | 0 | 0 |
... ; Domain=lab.test; Secure; HttpOnly | 0 | 10 | 0 | 10 |
Every cell was the same in all ten attempts, in both builds.
HttpOnly hid the value from script and changed nothing else. With it, document.cookie was empty in every attempt; without it, the page could read sid=v1. In both cases a fetch from the page carried the cookie, as MDN says it will: "a cookie that has been created with HttpOnly will still be sent with JavaScript-initiated requests". So a missing HttpOnly matters exactly when there is script injection on the cookie's origin, and what it adds to the injection is the value itself: an attacker who has it can use the session from their own machine, after the victim closes the tab, and, unless the server ends it, after the victim logs out. HttpOnly does not stop injected script acting as the victim while the page is open. It is worth fixing everywhere; on its own, it is not a finding that anything can be stolen. The cross-site scripting finding is.
Secure decided whether the value crossed plain HTTP. Without Secure, both builds sent sid=v1 to the plain-HTTP port in every attempt, and the server saw it over plain HTTP. A cookie set over HTTPS is not bound to HTTPS, or to the port. RFC 6265bis says it directly: "Cookies do not provide isolation by port", and "Cookies do not provide isolation by scheme". Section 8.3 of the draft spells out the attack: an active network attacker redirects any outbound plain-HTTP request to the server, and "Even if the webmail server is not listening for HTTP connections, the user agent will still include cookies in the request." With Secure, neither build sent the cookie to the plain-HTTP listener in any attempt. So a missing Secure is exploitable when a browser can be made to send a plain-HTTP request to the host: no HSTS, HSTS not preloaded and not yet seen, or a plain-HTTP listener on any port. Under preloaded HSTS it is close to a hygiene note; elsewhere it discloses the session to anyone on the network path, and, as the next sections show, it also decides whether that attacker can overwrite the cookie.
Domain widened the audience. With Domain=lab.test the sibling received the cookie in every attempt; without a Domain attribute the cookie was host-only and it never did. A broad Domain makes every subdomain part of the session's trust boundary: anything that can run on one of them, or any one that can be taken over (see the dangling DNS post), receives the session.
Path was not a boundary. A cookie set with Path=/p/app was not sent on requests to /p/other, and script on /p/other did not see it in its own document.cookie. But a page on /p/other that loaded /p/app/x in an iframe read sid=v1 from the frame's document.cookie in 10 of 10 attempts, because the two paths are one origin. MDN says Path "is not intended as a security measure", and RFC 6265bis says Path "cannot be relied upon for security". A finding that rates a cookie as protected because of its Path is wrong; one that rates a narrow Path as a weakness is not a finding at all.
Expires and Max-Age decide what the browser keeps, not what the server accepts. A cookie set with Max-Age=999999999, about 31.7 years, was stored by both builds with an expiry 34,560,000 seconds away: 400 days, the cap RFC 6265bis recommends ("The RECOMMENDED limit is 400 days in the future"). In a separate test, a cookie with no Expires or Max-Age and a cookie with Max-Age=3600 were set in a browser profile on disk; after the browser was closed and started again on the same profile, the cookie with Max-Age was still stored and sent in all ten attempts, and the session cookie was gone in all ten. MDN warns that browsers with session restore also restore session cookies, "as if the browser was never closed", and Playwright's headless launch does not exercise that, so this result is about these builds as we ran them. The server-side half is the one that matters, and it is below: in our lab, a session cookie with Max-Age=3 was still accepted when replayed 4 seconds after it was set, one second after it expired, because only the browser had been told it expired.
SameSite is the attribute this series has measured most; the CSRF post and the WebSocket post cover what Lax, Strict, None and a missing attribute did in these same builds, and why a sibling subdomain is same-site. As in those posts, both cookie stores reported every cookie set here without SameSite as Lax.
A cookie's attributes are visible to the browser when it is set, and invisible to the server when it comes back: the Cookie header carries only names and values. RFC 6265bis puts the problem plainly: "it is impossible for a server to have confidence that a given cookie was set with a particular set of attributes." Name prefixes are the fix. A browser that supports them refuses to store a cookie whose name starts with the prefix unless the attributes match, so the name alone tells the server how the cookie was set. We sent each line below from the application and read the browser's cookie store; every row was the same in all ten attempts.
Set-Cookie | Sent from | Stored? |
|---|---|---|
__Host-sid=v; Secure; Path=/ | HTTPS | yes, host-only |
__host-sid=v; Secure; Path=/ | HTTPS | yes |
__Host-sid=v; Path=/ | HTTPS | no |
__Host-sid=v; Secure | HTTPS | no |
__Host-sid=v; Secure; Path=/p | HTTPS | no |
__Host-sid=v; Secure; Path=/; Domain=lab.test | HTTPS | no |
__HOST-sid=v; Secure; Path=/; Domain=lab.test | HTTPS | no |
__HOST-sid=v; Path=/ | HTTPS | no |
__Secure-sid=v; Path=/ | HTTPS | no |
__Secure-sid=v; Secure; Path=/; Domain=lab.test | HTTPS | yes, for .lab.test |
__Secure-sid=v; Secure; Path=/ | plain HTTP | no |
sid=v; Secure; Path=/ | plain HTTP | no |
__Http-sid=v; Secure; Path=/ | HTTPS | no |
__Http-sid=v; Secure; HttpOnly; Path=/ | HTTPS | yes |
__Host-Http-sid=v; Secure; Path=/ | HTTPS | no |
__Host-Http-sid=v; Secure; HttpOnly; Path=/ | HTTPS | yes |
__Host- needs Secure, Path=/ written out, and no Domain; RFC 6265bis says such a cookie is "set with a Secure attribute, a Path attribute with a value of /, and no Domain attribute", and a line that left Path to its default was refused even though the default here was /. Both builds matched the prefix without regard to case, as the draft now requires ("UAs MUST match the prefix string case-insensitively", section 5.4), so __HOST-sid with a Domain was refused rather than stored as an ordinary cookie. __Secure- needs only Secure and a secure origin, and allows Domain. MDN also lists __Http- and __Host-Http-, which add a requirement for HttpOnly; both builds enforced them. Neither of those two prefixes is in RFC 6265bis draft 22, and MDN warns that "You cannot count on these additional assurances on browsers that don't support cookie prefixes; in such cases, prefixed cookies will always be accepted", so treat them as a property of the browsers you measured.
Reading the session is one problem; choosing it is the other, and it is what session fixation needs. Two attackers can set cookies a browser will send to app.lab.test without any bug in the application. RFC 6265bis calls this weak integrity: "Cookies do not provide integrity guarantees for sibling domains (and their subdomains)". A sibling can set a cookie with Domain=lab.test, and a network attacker can answer a plain-HTTP request to the host with a Set-Cookie of its own.
We set a legitimate session cookie first, or none, then had the sibling or the plain-HTTP listener set a cookie with the same name and the value evil, and read the Cookie header the application received on / and on /login. The plants used either Path=/ or the narrower Path=/login.
| Legitimate cookie | Sibling, Path=/ | Sibling, Path=/login | Plain HTTP, Path=/ | Plain HTTP, Path=/login |
|---|---|---|---|---|
| None | both: sid=evil | /login: sid=evil | both: sid=evil | /login: sid=evil |
sid, Secure, host-only | both: sid=legit; sid=evil | /: sid=legit; /login: sid=evil; sid=legit | refused | refused |
__Secure-sid | both: legit; evil | /: legit; /login: evil; legit | refused | refused |
__Host-sid | refused | refused | refused | refused |
"Both" means the same header on / and on /login; "refused" means the browser did not store the attacker's cookie and the application received only its own. Every cell was the same in all ten attempts, in both builds.
With no session cookie yet, both attackers won. The sibling's cookie, and the plain-HTTP listener's host-only cookie without Secure, were sent to the HTTPS application as its session cookie. A non-Secure cookie set over plain HTTP is sent over HTTPS too. That is the position of a visitor who has not loaded the site yet.
Secure on the existing cookie stopped plain HTTP, on either path. RFC 6265bis requires this: a non-Secure cookie is ignored when a Secure cookie of the same name already covers its path, so that "a newly-created, non-secure cookie does not overlay an existing secure cookie, providing some mitigation against cookie-fixing attacks". So Secure is also an integrity control, not only a confidentiality one, but only for a browser that already holds the cookie.
The sibling was not stopped by Secure or by __Secure-. It runs on HTTPS, so it can set Secure cookies, and __Secure- allows Domain. The browser then sent two cookies with the same name. RFC 6265 orders them: "Cookies with longer paths are listed before cookies with shorter paths", and, for equal paths, "cookies with earlier creation-times are listed before cookies with later creation-times". Both builds followed it. With Path=/, the application's own cookie came first and the sibling's last; with Path=/login, the sibling's came first, on the login path only.
Which one the server uses depends on its cookie parser, which may take the first value of a repeated name or the last; Python 3.12.3's http.cookies.SimpleCookie, given sid=evil; sid=legit, kept the last. An attacker can be first, with a longer Path, or last, with the same Path set later, so neither choice is a defence. Refusing a request that carries two values for the session cookie is one.
__Host- stopped all four. The sibling cannot set a __Host- cookie because it needs Domain to reach the application, and plain HTTP cannot set one at all.
CWE-384 describes the weakness as "Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier". RFC 6265bis section 8.4 describes the attack in three steps: the attacker "transplants a session identifier from his or her user agent to the victim's user agent", the victim uses it, and then the attacker "uses the session identifier to interact with server directly". The OWASP cheat sheet's rule is that "The session ID must be renewed or regenerated by the web application after any privilege level change", with login the common case and password changes, permission changes and switching to an administrator role named alongside it.
The obvious automated check is to capture the session cookie on the login page, log in, and compare it with the value afterwards: same value, fixation; different value, fine. That compares two strings. Fixation is a statement about a third thing: whether the value from before login is accepted as the victim after login. The WSTG's session-fixation test (WSTG-SESS-03) does it that way: save the cookie jar before login, log in as the victim, put the saved jar back, and try something only the victim can do.
The probe ran both checks against each variant. "Header diff" is the comparison of the two captures. "Old jar" replays the complete pre-login cookie jar after login and records whose session it is. "Chosen value" sends a session cookie the attacker made up, attacker-chosen-0001, to the login page, logs in with it, and replays it.
| Variant | Header diff says | Old jar after login | Chosen value after login |
|---|---|---|---|
| Keeps the pre-login identifier | not rotated | the victim | nobody (a new identifier was issued for it) |
| Keeps it, and accepts identifiers it did not issue | not rotated | the victim | the victim |
| New identifier at login, old one deleted | rotated | nobody | nobody |
| New identifier at login, old one kept | rotated | the victim | nobody |
| Accepts identifiers it did not issue, new one at login | rotated | nobody | nobody |
| No session before login | no cookie before login | (nothing to replay) | nobody |
| Pre-login cookie kept, a second cookie issued at login authenticates | not rotated | nobody | (not run) |
| Session held in a signed cookie, no server-side state | rotated | nobody | nobody (bad signature) |
Every row was the same in all five trials.
The comparison was wrong twice, in both directions. Against the server that issued a new identifier but kept the old session alive, it saw a new value and passed, while the old jar was the victim in every trial: a fixation the check is built to miss. Against the design that kept a pre-login cookie and authenticated with a second cookie issued at login, it saw an unchanged sid and failed, while the old jar was nobody in every trial. That second shape is common wherever a pre-login cookie carries a basket, a language or a consent choice; the WSTG introduction to its fixation test describes exactly that case, session cookies "used to store state information even before login, e.g., to add items to a shopping cart". Where the server had no session before login, the comparison had nothing to compare.
Accepting unknown identifiers is the cheat sheet's "permissive" mechanism, which "allows the web application to initially accept any session ID value set by the user as valid". With it, a value the attacker invented was the victim's session after login in every trial, so the attacker does not need to fetch one or keep it alive. Combined with rotation at login, it did no harm in our tests: the invented value was replaced at login. Rotation is the control; strictness removes a step for the attacker.
A signed cookie rotates by construction, because its content changes when the user logs in, so the comparison passes and the replay finds nothing. Its problems are elsewhere, below.
The probe shows the server will authenticate a value it issued before login. For an attack, the attacker also has to put that value into the victim's browser, and the previous section shows two ways: a sibling subdomain, and a plain-HTTP response. The last experiment does it in a browser. The attacker fetches the login page with a raw client and keeps the session value the server issues (or, where the server issues none, makes one up). The victim's browser visits the attacker's page on evil.lab.test, which sets that value with Domain=lab.test. The victim then opens the real login page, fills in the form and submits it. Finally the attacker replays the value from outside the browser. We ran two cases: a victim with no cookie for the application yet, where the sibling plants with Path=/, and a victim who had already loaded the login page and holds a cookie of their own, where the sibling plants with Path set to the login form's action so that its cookie is listed first on the login request.
Each cell is "victim logged in / attacker replay got the victim's account", out of 10 attempts.
| Variant | Victim had no cookie | Victim already had a cookie |
|---|---|---|
| Keeps the pre-login identifier, reads the first value | 10 / 10 | 0 / 10 |
| Keeps it, reads the last value | 10 / 10 | 10 / 0 |
| New identifier, old one deleted, reads the first value | 0 / 0 | 10 / 0 |
| New identifier, old one deleted, reads the last value | 10 / 0 | 10 / 0 |
| New identifier, old one kept | 10 / 10 | 10 / 10 |
| Keeps it, and accepts identifiers it did not issue | 10 / 10 | 0 / 10 |
| No session before login (attacker's value invented) | 0 / 0 | 10 / 0 |
| Pre-login cookie kept, second cookie issued at login | 10 / 0 | 0 / 0 |
As the first row, cookie named __Host-sid | 10 / 0 | 10 / 0 |
As the sixth row, cookie named __Host-sid | 10 / 0 | 10 / 0 |
Every cell was the same in all ten attempts, in both builds.
Where the server kept an identifier the attacker knew, the attacker got the account whenever the server read the planted value: in every attempt against a fresh victim, and in every attempt against a victim with a cookie of their own when the server read the first value. In that second case the victim's own login did not take, because the login request authenticated the attacker's cookie rather than theirs; the victim sees a failed login, and the attacker holds the account.
The server that issued a new identifier and kept the old one lost in every attempt, in both cases. It is the variant the before-and-after comparison passed.
__Host- ended the attack before it started. The sibling's Set-Cookie for __Host-sid with a Domain was refused in every attempt, so nothing was planted, and the two servers that were otherwise exploitable logged the victim in and gave the attacker nothing.
A server that rotated correctly still lost the victim's login. Against a fresh victim, a server that issued a new identifier and read the first value failed to log the victim in, 10 of 10, and gave the attacker nothing. After login the browser held two sid cookies with Path=/: the sibling's, which was older, and the application's new host-only one. The older one was listed first, and it named a session the server had just deleted. Reading the last value fixed it. The invented-value row failed the same way against a fresh victim. The second-cookie design failed against a victim who already had a cookie, for a different reason: the login request carried the sibling's value first, so the server bound its new authentication cookie to that value, and the victim's next request, carrying their own, matched nothing. That is not fixation, and no scanner holding one session would see it, but it is a sibling subdomain able to log users out of the application, and the same fix, a __Host- cookie, removes it.
The OWASP cheat sheet's requirement is that "Session identifiers must have at least 64 bits of entropy", and that "A strong CSPRNG (Cryptographically Secure Pseudorandom Number Generator) must be used to generate session IDs". Both are properties of the generator. A scanner, or anyone outside the server, has only a sample of its output, and a "low entropy" or "predictable token" finding is a statistical statement about that sample. Two things limit it: the sample is finite, and a statistic measures how evenly characters and bits are spread, not whether someone who knows the construction can compute the next value.
We generated tokens with six generators, took five samples at each of five sizes, and computed two statistics. The first is a character-level estimate: for each character position, the Shannon entropy of the characters seen there, summed over positions. The second is bit-level: for each bit position, a test of whether ones and zeros are equally likely, at the 1 percent significance level, counting the positions that fail. Neither is any particular tool's algorithm; both are the kind of test such tools describe.
Character-level estimate in bits, mean of five samples:
| Generator | True unpredictability | 20 tokens | 100 | 1,000 | 10,000 | 20,000 |
|---|---|---|---|---|---|---|
secrets.token_urlsafe(32), 43 base64url characters | 256 bits | 172.7 | 234.0 | 254.1 | 255.8 | 255.9 |
secrets.token_hex(16), 32 hex characters | 128 bits | 107.5 | 124.4 | 127.7 | 128.0 | 128.0 |
| MD5 of a counter, hex | none, to anyone who guesses the construction | 107.9 | 124.5 | 127.7 | 128.0 | 128.0 |
Python random.getrandbits(128) (Mersenne Twister), hex | predictable from 156 outputs (below) | 106.5 | 124.3 | 127.6 | 128.0 | 128.0 |
secrets.token_hex(4), 8 hex characters | 32 bits | 27.2 | 31.0 | 31.9 | 32.0 | 32.0 |
| Millisecond timestamp in hex, then 32 random bits | about 32 bits plus a guess of the time | 27.1 | 31.6 | 33.6 | 38.2 | 38.0 |
Small samples under-report good tokens. With 20 tokens, no position can show more than log2(20), about 4.3 bits, however random it is, so a 256-bit base64url token whose characters carry 6 bits each measured as 172.7 bits, and a 128-bit hex token as 107.5. Both converge on the true value by 10,000 tokens. PortSwigger's Burp Sequencer documentation makes the same point about its own character-level tests: "you can't draw a reliable conclusion from a sample size of 100 if a token uses 64 different characters at each position", and it says results compliant with the formal FIPS standard need "a sample of 20,000 tokens". A "low entropy" finding computed from the handful of tokens a crawl happens to collect is a measurement of the sample size.
Random bits fail some tests by chance. At a 1 percent level, about one in a hundred perfectly random bit positions fails. For the 128-bit CSPRNG token, the number of failing positions per sample ranged from 0 to 6; for the MD5 and Mersenne Twister tokens, 0 to 3 and 0 to 5. The base64url token always showed at least two failures, because the encoding leaves two bits of its last character at zero; a fixed bit is a property of the encoding, not of the generator.
Statistics cannot see a deterministic generator. MD5 of a counter and the Mersenne Twister were indistinguishable from the CSPRNG on both statistics at every sample size. PortSwigger's documentation says this too: "an algorithm which calculates the hash of a sequential number, may appear to generate random output". So we attacked the Mersenne Twister directly. Python's documentation says its random module "should not be used for security purposes" and calls the generator "completely unsuitable for cryptographic purposes". Its state is 624 32-bit words, and each output word can be inverted to a state word. Each 128-bit token is four words, so 156 consecutive tokens give the whole state. In each of five runs, with a fresh unknown seed, rebuilding the state from 156 observed tokens predicted the next 1,000 tokens exactly, 1,000 of 1,000. That is CWE-338, "Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)", and no randomness statistic would have flagged it.
What statistics did catch. The timestamp token failed visibly at every sample size: 42 to 46 of its 76 bit positions failed and most of the timestamp's bits never changed, because tokens issued close together share their leading characters. The short token was caught by its length, not its statistics: 8 hex characters cannot hold more than 32 bits, half the OWASP floor, although every statistic said it was perfectly random. One of the five 20,000-token samples contained a duplicate; for 20,000 draws from a 32-bit space the chance of at least one is about 1 in 20.
So a low-entropy finding needs a large sample before it says anything, and a clean entropy result says nothing about predictability. The questions that settle it are about the generator: what produces the identifier (a framework's session manager, secrets, crypto.randomBytes, SecureRandom, or random, Math.random, a hash of a timestamp or a user ID), and how many bits of its output reach the token. That is usually a five-minute code review and an impossible black-box test.
A logout has two halves. The browser forgets the value, and the server stops accepting it. Only the second protects anyone: whoever copied the value before logout, through an XSS, a proxy log, a shared machine or a stolen device, still holds it. The OWASP cheat sheet calls server-side invalidation "the most relevant and mandatory from a security perspective", and WSTG-SESS-06 names the common mistake: "the client-side session token is set to a new value while the server-side state remains active and can be reused by setting the session cookie back to the previous value." The same WSTG page describes frameworks that "rely solely on the session cookie to identify the logged-on user", with no server-side tracking.
The probe logged in, logged out with the session cookie, and replayed the same value.
| Variant | Logout response | Replay after logout |
|---|---|---|
| Server deletes the session | 200, Set-Cookie: sid=; Path=/; Max-Age=0; Secure; HttpOnly; SameSite=Lax | nobody |
| Clears the cookie only | the same | the victim |
| Signed cookie, no server-side state | the same | the victim |
| Signed cookie, per-user version checked on every request and incremented at logout | the same | nobody |
Every row was the same in all five trials, and all twelve variants the probe logged out of sent the same status, the same Set-Cookie line and, from the same handler, the same body. A scanner reading the logout response sees "cookie cleared" from all of them. Two of the four designs above kept accepting the old value.
A signed, self-contained session cookie has nothing on the server to delete, and RFC 6265bis says what signing does not do: "encrypting and signing cookie contents does not prevent an attacker from transplanting a cookie from one user agent to another or from replaying the cookie at a later time." The version-check variant shows the usual repair and its cost: incrementing a per-user counter ended the session, and ends every session that user holds, on every device. The cheat sheet's current text also asks that "All session IDs belonging to the same logical authenticated session must be revoked together", including IDs from rotations and grace periods.
A password change is the user's answer to "someone else might have my session". CWE-1466 describes the weakness as failing to "invalidate any current authenticated sessions after this authentication credential change". The probe logged in twice, as two devices, changed the password from the first, and replayed both.
| Variant | Other device's session after the change | First device, old value | First device, value issued with the change |
|---|---|---|---|
| Ends the user's other sessions and issues a new one | nobody | nobody | the user |
| Changes only the password | the user | the user | (no new value issued) |
| Signed cookie, no server-side state | the user | the user | (no new value issued) |
| Signed cookie, per-user version incremented at the change | nobody | nobody | the user |
Every row was the same in all five trials. Here "the user" is the right answer in the last column and the wrong one in the other two: after "change my password", a copy of either device's old session value still worked in the second and third designs. The single-session variant is left out of this table, because its second login had already ended the first. As with logout, the response to the change looks the same whichever design is behind it; the replay is the evidence.
The cheat sheet separates two timers. An idle timeout ends a session after a period with no requests. An absolute timeout ends it a fixed time after it was created, "regardless of session activity", and it is the one that limits an attacker: the idle timeout "does not limit the attacker's actions, as they can generate activity on the session periodically". It also says expiry "must be enforced server-side".
The probe logged in and replayed the value after 4 seconds of silence, then, in a new session, every 2 seconds for 12 seconds, with a 3-second idle limit and an 8-second absolute limit where the variant had them.
| Variant | Replay after 4 s idle | Replays every 2 s, at about 2, 4, 6, 8, 10 and 12 s |
|---|---|---|
| No timeout on the server | accepted | accepted at every replay |
| Idle timeout only, 3 s | refused | accepted at every replay |
| Idle 3 s and absolute 8 s | refused | accepted at 2, 4 and 6 s; refused from 8 s |
No server timeout, cookie set with Max-Age=3 | accepted | accepted at every replay |
| Signed cookie, no expiry | accepted | accepted at every replay |
Every row was the same in all five trials.
An idle timeout alone did not limit a session someone kept busy. With a replay every 2 seconds, the idle-only session was alive at 12 seconds, four times its idle limit and past the point where the absolute limit ended the other variant's session.
Max-Age limited the browser, not the server. The variant that put its 3-second lifetime only in the cookie accepted the replayed value at 4 seconds and at every replay after. A finding that reads "session expires after 3 seconds" from the Set-Cookie line has measured an instruction to the browser.
A timeout rated from the Set-Cookie line, or from how long a crawl stayed logged in, has observed neither timer.
Whether one account may hold several sessions at once is a design decision, and the cheat sheet treats it as one: an application that does not want simultaneous logons "must take effective actions after each new authentication event". The development version of the WSTG has a test for it, WSTG-SESS-11. The probe logged in twice and replayed the first value.
In every variant but one, the first session still worked after the second login, in all five trials. The variant that allowed one session per user ended the first session at the second login, 5 of 5.
A scanner holding one session cannot see this at all, and a second session that still works is not a vulnerability unless the application promises otherwise. What concurrent sessions change is the blast radius of the other findings: with no limit and no list of active sessions, a stolen or fixed value can be used alongside the victim's own session, and nothing tells the victim.
The procedure is general practice. It needs authorisation for the target and two test accounts you control, a victim and an attacker, and nothing in it touches a real user's session.
Set-Cookie lines, not the cookie store. For every cookie set at and after login, write down Secure, HttpOnly, SameSite, Domain, Path, Expires/Max-Age and any prefix. Find out which cookie, or which combination, actually authenticates: remove each from a logged-in request and see which one the server needs.__Host- prefix, and a parser that does not reject a second value)? Can a plain-HTTP response set it (no Secure on the existing cookie, no prefix, no HSTS)? Do it end to end with the two accounts: plant from the sibling, log in as the victim in a named browser, replay as the attacker.| Change | Held against | Did not hold against |
|---|---|---|
| New identifier at login, old one deleted on the server | a planted pre-login value, in the probe and in the browser | nothing in our tests, though with a first-value parser a tossed cookie broke the victim's login, 10 of 10 |
| New identifier at login, old one kept | the before-and-after comparison | a planted value, in every probe trial and every browser attempt |
| Refusing identifiers the server did not issue | an invented value | a value the attacker fetched from the login page, when the server kept it at login |
| Reading the last of two same-name cookies | a sibling cookie on the longer /login path | a sibling cookie on the same path, which both builds listed last (order measured; not run end to end) |
Secure on the existing session cookie | a plain-HTTP overwrite or shadow, on either path | a plain-HTTP plant before the victim had a cookie; any sibling |
__Secure- prefix | plain HTTP | a sibling, which set a second cookie of the same name |
__Host- prefix | the sibling and plain HTTP, on both paths, and fixation end to end against two vulnerable servers | — in our tests |
HttpOnly | document.cookie, on any path | a fetch from the page, which carried the cookie |
| Clearing the cookie at logout | the browser's own copy | a replayed copy, 5 of 5 |
| Deleting the session on the server at logout | a replayed copy | — in our tests |
| Signed session cookie with no server-side state | — | a replay after logout, after a password change, and after any amount of time |
| Per-user version checked on every request | a replay after logout or a password change | — in our tests, at the cost of ending every session the user holds |
Max-Age on the cookie | the browser's own copy | a replayed copy, after expiry |
| Server idle timeout alone | an idle replay | a session kept busy every 2 s, alive at 12 s |
| Server idle and absolute timeouts | both replays | — in our tests |
What the held rows share:
__Host-, with Secure, HttpOnly, Path=/ and no Domain. In both builds nothing else stopped both a sibling and plain HTTP. The cheat sheet's example is Set-Cookie: __Host-SessionID=<value>; Secure; HttpOnly; SameSite=Strict; Path=/.Max-Age is an instruction to the browser.Most of this is easier to read in code than to infer from responses. Find where the session is created, and check that the login handler calls the framework's regenerate function and what happens to the old session. PHP's session_regenerate_id() is an example of why that second check matters: it takes a delete_old_session argument that defaults to false, and the PHP manual explains that deleting immediately loses sessions on unstable networks. Its own example instead stamps the old session with a "destroyed" time and refuses it after 300 seconds. An old identifier accepted for a short, enforced grace period is a design trade-off, which the cheat sheet's logout section anticipates; one accepted indefinitely is the "new identifier at login, old one kept" row in the tables above. Find the logout and password-change handlers and check what they do on the server, not only to the cookie. Read the session configuration: cookie name and prefix, Secure, HttpOnly, Domain, idle and absolute lifetimes, whether expiry is checked on the server, and whether unknown identifiers are accepted (PHP's session.use_strict_mode, which makes it refuse uninitialised identifiers, "Defaults to Off", and the cheat sheet notes that PHP defaults to permissive). For a hand-written session layer, find the token generator and check it is a CSPRNG. A pattern search finds random, Math.random, uniqid or a hash of a timestamp near a session or token; whether the value reaches the session cookie is a dataflow question, and the SAST false-positive post is about the gap between those two.
| Question | If the answer is no or unknown |
|---|---|
Did the finding come from a Set-Cookie line alone? | An attribute finding needs the condition that makes it exploitable: an injection for HttpOnly, a plain-HTTP request for Secure, a hostile host for Domain |
Is the session cookie named __Host-? | Without it, a sibling planted a session value the application read, in both builds |
| Does anything on the host answer plain HTTP, and is HSTS preloaded? | Without Secure, both builds sent the session to a plain-HTTP port, 10 of 10 |
| Was fixation tested by replaying the pre-login cookie jar? | The before-and-after comparison missed a kept old session and flagged a second-cookie design |
| Does the server accept identifiers it did not issue? | An invented value became the victim's session, 5 of 5 |
| What does the parser do with two cookies of the same name? | A tossed cookie decided whose session a login authenticated, or broke the login |
| Was the old value replayed after logout? | Two of four logout designs sent identical headers and kept accepting it |
| Was another device's session replayed after a password change? | Two designs kept both devices logged in |
| Was a busy session replayed at the absolute limit? | An idle-only timeout kept a session with a 2-second keep-alive alive at 12 s |
Is expiry enforced on the server, or only in Max-Age? | A Max-Age=3 session answered a replay at 4 s |
| How many tokens were sampled for an entropy finding? | Twenty tokens measured a 256-bit token as 172.7 bits |
| What generates the identifier? | MD5 of a counter and the Mersenne Twister passed every statistic, and 156 tokens predicted the next 1,000 |
What does a missing HttpOnly flag actually allow? Injected script on the cookie's origin can read the session value and send it elsewhere, so the attacker can use the session from their own machine after the victim closes the tab. It needs an injection to exploit, and HttpOnly does not stop injected script making requests as the victim: in our lab a fetch from the page carried the HttpOnly cookie in every attempt.
Is a session cookie without the Secure flag exploitable on an HTTPS-only site? Only if a browser can be made to send a plain-HTTP request to that host. Without Secure, both Chromium builds we tested sent the session cookie to a plain-HTTP listener on another port of the same host in every attempt. HSTS that is preloaded or already seen prevents the plain-HTTP request; without it, an active network attacker can trigger one.
How do I test for session fixation? Save the cookie jar on the login page, log in as a test victim, put the saved jar back and request something only the victim can see. If it works, the identifier was not invalidated at login. Then establish whether an attacker can plant a value: a sibling subdomain, a plain-HTTP response, or a server that accepts identifiers it never issued. Comparing the session cookie before and after login is not the test; in our lab it reported fixation where there was none and missed it where there was.
Does regenerating the session ID at login prevent fixation? Only if the old identifier stops working. A variant that issued a new identifier at login but kept the old session alive passed the before-and-after comparison and let a planted value open the victim's account in every attempt.
Why does my session still work after logout? Because logout cleared the cookie in the browser but not the session on the server, or because the session lives entirely in a signed cookie and the server has nothing to revoke. Replay the old value after logout to find out; the logout response looks the same either way.
What is the difference between idle and absolute session timeout? An idle timeout ends a session after a period without requests; an absolute timeout ends it a fixed time after login regardless of activity. Only the absolute timeout limits an attacker who keeps a stolen session busy.
How many session tokens do I need to test entropy? Thousands. With 20 tokens no character position can show more than about 4.3 bits, so a 256-bit token measured as about 173 bits. PortSwigger's documentation says FIPS-compliant results need 20,000 tokens. And no sample size detects a deterministic generator: MD5 of a counter and Python's Mersenne Twister scored like a CSPRNG at every size.
Is CWE-613 still the right CWE for insufficient session expiration? Not since CWE 5.0 (October 2026), which deprecated it and prohibits mapping to it. Use CWE-1463 for a timeout that is too long or missing, CWE-1465 for a session not invalidated at logout, CWE-1466 for sessions not invalidated after a credential change, or, for invalidation in general, CWE-1464, the parent of CWE-1465 and CWE-1466.
Our own toy server and two headless Chromium builds, and nothing else. Not tested: Firefox, Safari, any other Chromium-based browser or version, a headed browser, or a browser with session restore enabled; any web framework's session manager, including what any framework's regenerate function, logout or cookie parser does; HSTS in any form; a real network attacker, as opposed to a listener on another port of the same host; public suffixes, and cookies set on registrable-domain boundaries; third-party cookie restrictions or partitioned cookies; the Cookie Store API; device-bound session credentials; bearer-token sessions, which the JWT post covers; single sign-on and federated logout; session puzzling (WSTG-SESS-08) and exposed session variables (WSTG-SESS-04); real timeout values, since ours were seconds; and any scanner, ours included. The entropy statistics are our own simple versions, not any tool's implementation.
Secure session cookie to a plain-HTTP port every time. Secure is also what stopped a plain-HTTP response overwriting the session cookie, so on an application that keeps identifiers across login it matters more. Fix it with a __Host- name.AppSecD's dynamic and API testing runs Nuclei, Dalfox, SQLMap, Commix, Katana, Arjun, FFuf and Interactsh for out-of-band detection, plus 150+ native checks and API discovery across 50+ web frameworks. Its policy-driven gating blocks a pull request or commit when it introduces a violation. Findings are deduplicated across scans, move through new, reopened and fixed states, and can require maker-checker approval before they are closed.
That is the whole claim. data/products.ts is the single source of truth for what these products do, and it does not mention session management, cookie attributes, cookie prefixes, session fixation, logout, timeouts or session-ID entropy. So this post makes no claim that AppSecD tests for any of them. Nor does it claim anything about:
The mechanisms, measurements, confirmation procedure, fixes and checklist above are general practice that applies to any scanner's output, ours included. The scenario in this post is hypothetical and does not describe any deployment, user or finding.