Course contentsShow
← Security
Lesson 714 of 3,05215. Web Security - Authentication and SessionsFree lesson

Session Fixation Attacks

Exploiting session fixation vulnerabilities where attackers force users to use a predetermined session identifier.

What You'll Learn

You'll learn how attackers force a user to adopt a known session ID, allowing the attacker to hijack the session after the victim logs in.

What is Session Fixation?

Session fixation is an attack where the attacker sets a victim's session identifier before the victim authenticates. Unlike session hijacking (where attackers steal an existing valid session), fixation involves the attacker giving the victim a session ID that the attacker already knows.

Here's how it works:

  1. Attacker obtains a valid session ID from the target website (often by visiting it themselves)
  2. Attacker tricks the victim into using that specific session ID (via malicious link, email, or social engineering)
  3. Victim logs in using the attacker-controlled session ID
  4. Application keeps the same session ID after successful authentication
  5. Attacker uses the known session ID to access the victim's authenticated session

Real-World Analogy

Imagine a coat check at a restaurant. The attacker gets ticket #42 but doesn't leave a coat. They trick you into using ticket #42 for your expensive jacket. After you leave, the attacker presents ticket #42 and walks away with your jacket—because the restaurant didn't issue you a new ticket when you checked in.

Common Attack Vectors

  • URL parameters: http://bank.com/login?sessionid=attacker123
  • Cookie injection via HTTP response splitting (less common with modern browsers)
  • Cross-site cookie setting on subdomains or related domains

Why Applications Are Vulnerable

The core vulnerability: the application doesn't regenerate the session ID upon authentication. It trusts the session ID the user arrived with.

Key Takeaway: Session fixation succeeds when applications fail to issue a fresh session identifier after login, allowing attackers to pre-set a victim's session and hijack it post-authentication.