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
Session IDs generated from a simple incrementing counter are vulnerable to which attack?
- Token prediction (guessing)
- Clickjacking
- ARP cache poisoning
- 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.
Which conditions make cookie theft through XSS easier?
- The session cookie lacks the HttpOnly attribute
- User input is reflected in pages without output encoding
- The cookie carries the Secure attribute
- Session tokens stay valid for weeks
- 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: 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.
