41. Session Hijacking – Tokens, Cookies and Defence
41.3 Session Fixation and Predictable IDs
Session fixation: attacker sets (or knows) a session ID before victim logs in; victim authenticates into that same ID; attacker reuses it. Classic weak pattern: accept attacker-supplied session ID and never regenerate after successful login.
Predictable IDs: if session IDs are short, sequential, or weak RNG, Red can guess. Modern frameworks use long random IDs – still regenerate on privilege change.
Blue classics:
session_regenerate_id(true)(PHP) after successful login- Reject / ignore attacker-chosen IDs where framework allows
- Never put session ID in bookmarks / email links if avoidable
| Red team (attacker) does | Blue team (defender) detects / stops |
|---|---|
| Plants known session ID; waits for victim login | Regenerate session ID on login; invalidate old |
| Guesses weak / sequential IDs | Cryptographically strong long IDs from framework |
| Shares "helpful" login URL with embedded SID | Avoid SID in URL; Prefer cookies + regenerate |
Ravindra Bagale's Tip
Students keep the same PHPSESSID even after a successful login. Close the fixation door: regenerate on login. One line for the interview: "I rotate the session identifier at authentication." Don't worry – one function call, a big difference.
Ravindra Bagale's Tip – मराठी
Students login success नंतर पण तोच PHPSESSID ठेवतात. Fixation चा दरवाजा बंद: regenerate on login. Interview साठी एक line: "I rotate the session identifier at authentication." घाबरू नका – एक function call, मोठा फरक.
Ravindra Bagale's Tip – हिंदी
Students login success के बाद भी वही PHPSESSID रखते हैं. Fixation का दरवाज़ा बंद: regenerate on login. Interview के लिए एक line: "I rotate the session identifier at authentication." घबराओ मत – एक function call, बड़ा फ़र्क.
Lab
Deliberate weak PHP on OWN VM: login without regenerate. From Kali, note SID before login (or set cookie), complete login as Rani in browser, replay SID from Kali curl – see authenticated page. Then add session_regenerate_id(true) after password OK. Prove old SID fails. Host-only only.
Real incident: Zammad / DIVD – session fixation chain to root (Sept–Oct 2026)
1. What happened
On 21 September 2026, attackers breached the Dutch Institute for Vulnerability Disclosure (DIVD) by chaining two zero-day flaws in the open-source Zammad helpdesk/ticketing platform. BleepingComputer (Bill Toulas, 30 September 2026) reported DIVD's description: the attack was driven by an autonomous AI agent that moved without external direction and left explanations of its decisions. The flaws are CVE-2026-102489 (session fixation / session hijack path that can lead to remote code execution as the zammad user) and CVE-2026-102490 (local privilege escalation from the Zammad user to root). On 2 October 2026, CISA added both CVEs to its Known Exploited Vulnerabilities (KEV) catalog. DIVD case DIVD-2026-00015 (last modified 1 Oct 2026) states RCE-affecting versions 6.3.0–6.5.4 (also present in 7.0.0–7.1.3 but "not exploitable due to environment conditions" per DIVD), and LPE affecting v1.5.0–v7.1.0-alpha. DIVD said network segmentation and incident response stopped deeper movement; investigation continued. Treat product customer counts and any "seconds" timing claims as reported — do not invent victim totals. Educational framing only.
2. How the hack happened (public reporting only – high-level) 1. Attackers targeted an internet-reachable Zammad ticketing instance (helpdesk systems often sit on the edge of support workflows). 2. They abused CVE-2026-102489 — a session fixation / session hijack class flaw that public reporting says can lead to remote code execution as the Zammad application user (no exploit steps here). 3. They then abused CVE-2026-102490 — a local privilege escalation so that same foothold could become root on the host. 4. With that access, an AI agent (per DIVD) automated follow-on actions: reach other services, read data, and exfiltrate — described as happening very quickly. 5. Segmentation + IR limited blast radius; DIVD later reproduced the bugs with Merlon Security, notified Zammad, scanned for exposed instances, and published limited disclosure (26 Sept 2026 timeline on DIVD's case page). CISA KEV listing (2 Oct 2026) raised global patch priority.
3. How to stop it / defend (this chapter: session fixation) - Inventory every self-hosted helpdesk / ticketing app (Zammad and peers) the same way you inventory VPN / SharePoint — public = emergency patch class. - Patch or upgrade: DIVD recommends Zammad 7+ (or take the instance offline); Zammad community guidance also pointed admins to current stable (7.2.0 as discussed in vendor posts) and to watch official security advisories for the LPE details. - Session defence that this lesson teaches: regenerate session ID on login, never accept attacker-chosen SIDs, strong random IDs, short TTL, Secure+HttpOnly cookies. - After a KEV / active-exploit alert: assume possible compromise on exposed hosts — check logs / IoCs (DIVD published a log-check approach), rotate credentials/sessions, and hunt before you only "version bump". - Segment ticketing hosts from crown-jewel networks so one app user → root path cannot walk the whole estate.
4. How to take care so it won't happen again (checklist) - [ ] Asset list names every public Zammad / helpdesk URL + exact version. - [ ] Patch SLA: CISA KEV / actively exploited internet-facing apps = emergency change. - [ ] Login flow regenerates session ID; old SID invalidated (lab: prove with YOUR PHP demo). - [ ] Ticketing host is segmented; admin MFA; no shared app→root shortcuts left unpatched. - [ ] Post-patch: review auth/session logs for fixation-style anomalies; rotate secrets if exposure window existed. - [ ] Tabletop: "helpdesk zero-day → session hijack → root" using NIST IR phases from Ch.31.
Source: CISA alert, 2 Oct 2026 (KEV add for CVE-2026-102489 / CVE-2026-102490); DIVD CSIRT case DIVD-2026-00015 (timeline / affected versions, modified 1 Oct 2026); BleepingComputer, Bill Toulas, 30 Sept 2026 ("DIVD says Zammad zero-days enabled AI-driven network breach").
Check if you're safe: Password Strength Checker · Website Security Checklist