Blacksec

Administrator
Staff member
ROOT
VIP
Session hijacking skips the password entirely — the attacker steals the ticket the browser already carries. Login screen, MFA prompt, strong password — all bypassed by grabbing a cookie or predicting a token. This guide covers every technique from network sniffing to fixation to XSS theft, plus the server-side locks that make stolen tickets expire mid-flight. Full breakdown below.

TL;DR — After login, the site trusts your session token — that token IS you. Steal it (XSS, network, fixation), predict it, or ride it through a shared connection, and the password becomes irrelevant. Techniques and defenses per vector below.

1. THE WRISTBAND (KID VERSION)

Kid version: amusement park. You prove age at the gate ONCE, get a wristband, then ride everything all day without showing the ticket again. Steal the wristband and you ride free — nobody re-checks your ticket at every roller coaster.

A session token works exactly like that wristband. Password gets shown once at login; the server hands back a token; every following request carries it. The server checks the token, not the password — a thousand requests, zero re-auths. Efficiency for the site, and a beautiful target for anyone who can read or copy that wristband.

The whole game: get the band off their wrist without them noticing. The password could be forty characters with symbols — irrelevant if the cookie is grabbable.

2. NETWORK-LEVEL HIJACKS

Packet sniffing. On shared networks — café Wi-Fi, compromised routers, ARP-poisoned LANs — unencrypted session cookies ride the wire in cleartext. Wireshark or tcpdump captures every frame; filter for "Cookie:" in HTTP traffic and the wristband falls out. This is why HTTPS everywhere matters: TLS encrypts the cookie in transit and sniffing yields garbage. SSL stripping (sslstrip) attacks the downgrade — forcing the browser to stay on HTTP while the site supports HTTPS, rewriting links as they go. HSTS kills this: the browser FORCES encrypted connections to a domain after learning the policy once.

Session fixation. Attacker obtains a valid session ID FIRST — visits the site, gets issued one — then plants that known ID on the victim (crafted link, XSS-set cookie on a sibling subdomain). Victim logs in, and the login binds to the ATTACKER'S pre-planted ID. Victim authenticated the attacker's wristband. Fix: servers must REGENERATE the session ID on privilege change — fresh band after login, old one dies. Sites that skip regeneration are handing out pre-known wristbands.

Cross-site request riding. Related family: CSRF does not steal the session, it BORROWS it — the victim's browser attaches their own cookie to a forged request (bank transfer page embedded as invisible img/form). The site sees a valid session doing something the user never clicked. Defense: synchronizer tokens per form, SameSite cookie attribute blocking cross-site attachment entirely.

3. CLIENT-LEVEL THEFT

  • XSS token grab — injected script reads document.cookie and ships it to the attacker (HttpOnly blocks the read — flag exists for this exact attack). Replay the cookie from attacker's browser, full session in hand.
  • Malware / infostealer — stealer malware dumps browser-saved cookies straight from the profile files on disk. No network attack, no exploit — just a downloader the victim ran. Session cookies in infostealer logs are a primary 2026 commodity because they bypass passwords AND MFA both.
  • Browser extension abuse — permissions that sound harmless ("read data on all pages") grant every page's tokens. One malicious extension = every logged-in session drained.
  • Physical / shared device — "remember me" sessions sitting in a browser at a library, an office, an ex's apartment. The cheapest hijack there is.

4. PREDICTION AND BRUTE FORCE

Historically famous, mostly extinct: early session IDs came from time() and process IDs — guess the clock, guess the session. PHPSESSID years ago fit in a small brute-force space; tools like Tamper Data automated enumeration. Modern frameworks use CSPRNG tokens, 128 bits minimum, where guessing is thermodynamically hopeless.

What remains: short tokens on embedded devices, custom PHP apps rolling their own generation, and IDOR-style parallelism — accessing OTHER users' session resources by ID when the server checks authentication but not OWNERSHIP. Different bug, same "your stuff, my session" result.

5. THE SERVER-SIDE LOCKS

DefenseWhat it killsNotes
TLS + HSTSsniffing, strippingencrypts cookie in transit, forces upgrade
HttpOnly + SecureJS read, http leakcookie never touches scripts or plaintext
SameSite=Strict/LaxCSRF attachmentbrowser won't send cookie cross-site
ID regeneration on loginfixationfresh token after every privilege change
Short TTL + rotationreplay windowsrefresh tokens rotate, old ones revoke
IP/device bindingremote replaytoken replayed from new device = challenge
Server-side logoutpost-theft usereal revocation, not just client-side delete

The rotation point deserves emphasis: even a stolen cookie dies fast when tokens refresh on every use and the old one self-invalidates. Attacker replays a token that already rotated — server rejects, session over. Combine with binding and hijack windows collapse from "months" to "seconds."

6. USER-SIDE HABITS

  • Log out on shared machines — closing the tab is not logging out.
  • Kill stale sessions: check "active sessions" in security settings quarterly, revoke the ones you don't recognize.
  • HTTPS only, HSTS-preloaded domains where possible; treat HTTP logins as public broadcasts.
  • Password managers autofill only on the real domain — phishing pages get nothing because the form origin does not match.
  • Avoid "remember me" on anything financial; the convenience is a stolen-wristband invitation.
  • Device hygiene — stealer malware is the number one cookie source in 2026, and it arrives through cracked software and fake installers.

7. FIELD CHEAT SHEET

VectorAttackCounter
Wiresniff / sslstripTLS + HSTS
Planted IDsession fixationregenerate on login
Injected scriptXSS cookie grabHttpOnly + output encoding
Forged requestCSRF rideSameSite + form tokens
Infostealercookie file dumpdevice hygiene + short TTL
Replay elsewheretoken reuserotation + device binding

— RELATED GUIDES —

Wristband grabbed, token rotated, session burned — every hijack ends with somebody riding for free and the owner still queued at the gate. Match vector to counter, regenerate on privilege, expire on use — and check the active-sessions list, because one of them might not be yours.
 
Last edited: