Bitzu

312-50 ยท Session hijacking

Application-level session hijacking

Session sniffing, predictable tokens, session fixation, XSS and CSRF-based theft, session replay, cookie theft, man-in-the-browser.

Key points

  • Attacks on the session token itself at the web layer: sniffing it from unencrypted traffic, guessing predictable IDs, session fixation (forcing a known ID on the victim before login), stealing cookies via XSS, replaying captured tokens, riding a victim's browser with CSRF or a man-in-the-browser trojan.
  • All of them end with the server accepting a token the attacker should not hold.

Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cookies

Practice questions

Single choice

Session IDs generated from a simple incrementing counter are vulnerable to which attack?

  1. Token prediction (guessing)
  2. Clickjacking
  3. ARP cache poisoning
  4. SYN flooding
Show answer

Answer: A. Token prediction (guessing)

Predictable IDs let an attacker guess other valid tokens after seeing a few of their own. IDs must come from a cryptographically secure random generator.

Select all that apply

Which conditions make cookie theft through XSS easier?

  1. The session cookie lacks the HttpOnly attribute
  2. User input is reflected in pages without output encoding
  3. The cookie carries the Secure attribute
  4. Session tokens stay valid for weeks
  5. The site uses HTTPS only
Show answer

Answer: A. The session cookie lacks the HttpOnly attribute, B. User input is reflected in pages without output encoding, D. Session tokens stay valid for weeks

Without HttpOnly, injected script can read document.cookie; unsanitised output provides the injection point; long-lived tokens give more time to reuse. Secure only affects transport and would not help the attacker.

True or false

True or false: a CSRF attack must steal the victim's session cookie to perform actions as the victim.

Show answer

Answer: False

False. CSRF makes the victim's own browser send a forged request with the cookie attached automatically; the attacker never sees the cookie.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More 312-50 topics in this module