Session Fixation: The Attack That Starts Before You Log In
Session fixation plants a session identifier in your browser before you authenticate, so the attacker already knows it. One line of code prevents it.

Most attacks on sessions work by theft. The attacker takes a cookie that already represents a logged-in user and replays it. Session fixation works the other way round, and the inversion is what makes it hard to reason about: the attacker hands the victim an identifier, waits for them to log in, and then uses the identifier they chose in the first place. Nothing is stolen, because nothing needed to be.
OWASP states the distinction precisely. "The session fixation attack is not a class of Session Hijacking, which steals the established session between the client and the Web Server after the user logs in. Instead, the Session Fixation attack fixes an established session on the victim's browser, so the attack starts before the user logs in."
How sessions work, briefly
HTTP does not remember anything between requests. To know that the person asking for your account page is the person who logged in a minute ago, the server issues an identifier, the browser sends it back with every request, and the server looks up what it means.
The identifier is a bearer token in the literal sense. Whoever presents it is treated as the person it belongs to. That is the entire security model, and it means two properties have to hold: the identifier must be unguessable, and the server's record of what it means must change at the right moments.
Session fixation is a failure of the second property. OWASP's description of the flaw is that when authenticating a user, the vulnerable application "doesn't assign a new session ID, making it possible to use an existent session ID." MITRE's definition of CWE-384 says the same thing from the developer's side: authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier.
The attack in six steps
OWASP's own worked example runs like this.
- The attacker establishes a legitimate connection to the web server, which issues a session identifier. Alternatively, the attacker proposes an identifier of their own choosing and the server accepts it.
- The attacker sends the victim a link containing that established session identifier.
- The victim clicks the link and reaches the site.
- The server sees that a session is already established, so it does not create a new one.
- The victim provides their credentials and logs in.
- The attacker, who knows the session identifier, now has access to the victim's account.
Step four is the vulnerability. Everything else is the attacker arranging the circumstances. Note what the attack does not require: no interception of traffic, no password, no malware on the victim's machine, and no second factor. The victim authenticated themselves, including any multi-factor step, into a session the attacker already held.
The ways an identifier gets planted
OWASP lists several techniques, and which ones apply depends on how the application handles session tokens.
- Session token in a URL argument. The identifier is sent to the victim in a hyperlink and they access the site through it. This is the easiest case and the reason accepting a session identifier from a query string is a design error rather than a convenience.
- Session token in a hidden form field. The victim is induced to authenticate through a login form the attacker built, hosted on the attacker's server or embedded in an HTML email, which submits to the real application.
- Setting the cookie with client-side script. Where a cross-site scripting flaw exists, the attacker writes to
document.cookieand fixes the value directly. Note the dependency: this variant needs a separate injection flaw. - A META tag. OWASP points out why this one is awkward to defend against: unlike script, which a browser can be told not to execute, the processing of these tags cannot be disabled.
- A crafted response header. If the attacker can influence the server's response, a
Set-Cookieheader inserts the value of their choosing into the victim's browser.
MITRE's extended description for CWE-384 adds a third scenario beyond the application failing to end the existing session and the attacker forcing a known identifier: the application or container using predictable session identifiers. Where identifiers can be guessed, the attacker does not even need to plant one, which is why CWE-384 is recorded as potentially following CWE-340, the generation of predictable numbers or identifiers.
Where it sits in the real exploitation picture
Honesty about frequency matters here, because this class gets written about more than it gets exploited at scale. Take CISA's Known Exploited Vulnerabilities catalog as it stood on 20 November 2026: of 1,790 entries, exactly one carries the CWE-384 tag.
That entry is worth looking at, because it shows the shape fixation takes when it does become serious. CISA added CVE-2026-102489 in October 2026, naming it a Zammad session fixation vulnerability and describing it as leading to remote code execution as the Zammad service user, chainable with CVE-2026-102490. The CVE record from the reporting coordination body describes Zammad versions 6.3.0 to 6.5.4 as vulnerable, notes that the bug is present in 7.0.0 through 7.1.2 but not exploitable there because of changes in the underlying framework, and carries CVSS version 4.0 scores of 8.7 and 9.4 depending on the scoring scenario. CISA's catalog entry also sets a forensic triage requirement, meaning agencies must check whether the asset was already compromised rather than only patching it.
Two lessons sit in that single entry. Vendors and CISA sometimes describe the same flaw with different vocabulary, since the vendor's record calls it a session hijack issue while the catalog names it session fixation. And a session flaw becomes a serious incident when it is the first link in a chain, not on its own.
The practical takeaway for prioritization is that session fixation belongs in your application security testing programme rather than at the top of your patch queue. For how to weigh a finding like this against everything else competing for attention, see our vulnerability management guide.
The fix, and the fix after that
The primary control is one line of logic in the right place. MITRE's architecture and design recommendation for CWE-384 is to "invalidate any existing session identifiers prior to authorizing a new user session." Regenerate at login, discard the old value, and the planted identifier becomes worthless at the exact moment it would have become valuable.
OWASP widens the requirement in a way that is easy to miss. The session identifier must be renewed after any privilege level change, rather than at login alone. Their list includes password changes, permission changes, and switching from a regular user role to an administrator role. An application that regenerates at login and nowhere else still has a window wherever privileges change mid-session.
Beyond that, the surrounding controls from OWASP's session management guidance do the rest of the work.
- Never accept a session identifier from a URL. This removes the easiest planting route outright, and it stops identifiers leaking through browser history, referrer headers, server logs and shared links.
- Generate identifiers properly. OWASP requires at least 64 bits of entropy produced by a cryptographically secure random generator, which in hexadecimal means at least 16 characters. Entropy is the requirement; length is only how you encode it.
- Set the cookie attributes deliberately.
Secureso the identifier is only ever sent over HTTPS, since OWASP notes that forcing the application to use HTTPS does not protect the identifier if the attribute is missing.HttpOnlyso injected script cannot read it. An explicitSameSitevalue ofStrictorLax, because OWASP advises against relying on the browser default, which varies by browser and version. - Use the
__Host-cookie name prefix for session identifiers. OWASP recommends it specifically, because it forcesSecure, forbids aDomainattribute and requires a root path, which prevents subdomain forgery and HTTPS downgrade. - Invalidate server-side on logout. Clearing the cookie in the browser is not invalidation. If the server still honors the value, anyone holding it still has a session.
- Fix cross-site scripting as a session control. Several fixation routes depend on an injection flaw, so an application with no script injection has fewer planting options available to an attacker.
MITRE also notes an application firewall as a moderate-effectiveness operational measure for cases where the code cannot be changed, with the usual caveats that it may miss input vectors and may block legitimate requests. Treat that as a holding position rather than a solution.
Fixation usually arrives as a link. The common delivery method is a crafted URL sent to the victim. Paste a suspicious link into CyberWatch AI Scan for a free check before you click it.
The short version
Session fixation exploits an application that keeps using the session identifier it issued before you authenticated. The attacker obtains or chooses an identifier, gets your browser to adopt it through a link, a form, injected script, a META tag or a response header, and then waits for you to log in. Your password and your second factor work exactly as designed, into a session someone else is already holding.
The fix is to issue a fresh identifier and destroy the old one at authentication and at every privilege change, never to accept an identifier from a URL, and to set the cookie attributes that keep it out of reach. For the theft-based attacks on sessions that happen after login, see our explainer on session and token theft, and for the authorization failures that sit alongside these, broken access control.
Frequently asked questions
What is session fixation?
An attack in which the attacker arranges for the victim's browser to use a session identifier the attacker already knows, then waits for the victim to log in. If the application does not issue a new identifier at login, the attacker's known identifier becomes an authenticated session.
How is session fixation different from session hijacking?
OWASP draws the line clearly: hijacking steals an established session after the user logs in, while fixation fixes a session on the victim's browser so the attack starts before they log in. The attacker never has to steal anything, because they chose the value.
What is the actual fix?
Issue a brand new session identifier at the moment of authentication and destroy the old one. MITRE's guidance for CWE-384 is to invalidate any existing session identifiers prior to authorizing a new user session. OWASP extends this to any privilege level change, including password changes and role switches.
How does an attacker set a session identifier in someone else's browser?
OWASP lists several routes: a session token carried in a URL the victim clicks, a hidden form field in a login form the attacker controls, a cookie set by injected client-side script, a META tag, or a crafted Set-Cookie response header. Each depends on how the application handles session tokens.
Does HTTPS prevent session fixation?
No. Encryption protects the identifier in transit and does nothing about which identifier is in use. Fixation does not require intercepting traffic, so transport security is not the relevant control here.
Do modern frameworks handle this automatically?
Most mainstream web frameworks regenerate the session identifier on login when their standard authentication flow is used. The risk concentrates in hand-rolled authentication, in applications that set a session identifier before login and keep it, and in code that accepts a session identifier from a URL parameter.
Is session fixation common in exploited vulnerability catalogs?
It is rare. In CISA's Known Exploited Vulnerabilities catalog as of 20 November 2026, out of 1,790 entries only one is tagged with CWE-384, the session fixation weakness. It is a real application weakness that does not drive mass exploitation the way injection and memory corruption flaws do.
What cookie settings matter for session identifiers?
OWASP's session management guidance calls for Secure so the cookie is only sent over HTTPS, HttpOnly so script cannot read it, an explicit SameSite value of Strict or Lax rather than the browser default, and the __Host- name prefix for session cookies to prevent subdomain forgery and HTTPS downgrade.
Sources
- Session fixation, OWASP
- CWE-384: Session Fixation, MITRE
- Session Management Cheat Sheet, OWASP
- A01:2021 Broken Access Control, OWASP
- CVE-2026-102489, CVE Program
- Known Exploited Vulnerabilities Catalog, US Cybersecurity and Infrastructure Security Agency
- CWE-1462: Improper Session Management, MITRE


