Cyberlium

Ethical › Module 11 › Lesson 2

BeginnerModule 11Lesson 2/5

How Sessions Get Stolen (Concepts)

XSS, open Wi-Fi, missing flags — not a hijack PoC.

15 min+40 XP4 quiz
Module progress2 of 5

Visual · session_stolen_concepts

Named leak paths: script on the origin (XSS) if HttpOnly is missing; cleartext on a path an observer can see; flags never set. Literacy only — no steal kit, no café tap, no live XSS.

Opening

Sessions get stolen when the secret leaves a vault you did not lock — not when you run a hijack kit against a stranger.

Lesson 1 defined the session token as the “already logged in” string: possession often equals identity until expiry or revoke. This lesson names how that string leaks. In Cyberlium wording the three beginner paths are: (1) script on the same origin reading a cookie that was not HttpOnly (cross-site scripting as a named bug, not a payload you fire at a live shop); (2) the cookie or bearer token riding cleartext HTTP on a path an allowed observer can see — Module 8 already called that volunteer traffic, and a café is still other people’s traffic; (3) missing flags and missing rotation so a copied value keeps working. Physical access to an unlocked browser is the unglamorous fourth. Session fixation is the named fifth: an id that survives login instead of being replaced. This is original Cyberlium teaching mapped to the CEH v13 session-hijacking domain — not official EC-Council training, not a cert, not exam dumps. You will not write an XSS payload against a live site. You will not steal cookies. You will not Wireshark café Wi-Fi. You will not replay a token. You will not BeEF, not cookie-grab gists, not “document.cookie to a webhook.” You will write the named paths and the matching fixes in one sentence each, then lock the notes. Next lesson is the flag and logout list: Secure, HttpOnly, SameSite, short TTL, revoke on password change. The lab after that inspects flags YOU set.

1. XSS as a named leak — HttpOnly is the cookie fix; you do not weaponize a shop

Cross-site scripting (XSS) means an attacker’s JavaScript runs in the origin of a site the victim is using — usually because the app echoed untrusted HTML or a script URL into the page. If a session cookie is readable from JavaScript (no HttpOnly), that script can read document.cookie and send the value elsewhere. That sentence is enough. It is the whole XSS→session story this module needs. You already met XSS as a named web bug in other Cyberlium paths. Here it is only a leak path for the “already logged in” string. The cookie-side mitigation is HttpOnly so the browser will not hand the cookie to script. The app-side mitigation is not echoing raw user input as HTML — output encoding, a Content-Security-Policy you actually ship, frameworks that escape by default. None of that is a payload. Pasting <script>…</script> into a production search box you do not own is unauthorized testing. Pasting it into a classmate’s homework app without writing is the same line.

If you need to see XSS safely, you do it later on a page YOU wrote, in a private lab, with no network exfil and no one else’s cookies. This lesson does not assign that page. Do not “practice” on a live bank, a school portal, a bug bounty out of scope, or a random shop. Do not fetch a cookie-stealer from a cert-acronym blog. Bearer tokens in localStorage have the same XSS problem without an HttpOnly equivalent — script that runs on the origin can read storage. That is why serious SPAs still prefer HttpOnly cookies for the session when the browser is the client, or keep tokens in memory with a short life. Write the pairing: XSS named, HttpOnly named, live payload refused.

Command guide

XSS named as a leak — WHAT/WHY (HttpOnly is the cookie fix)

═══ COMMANDS ═══

Command — copy this

cat >> "$NOTES" << 'EOF'
xss_leak: script in the page can read document.cookie unless HttpOnly
fix_flag: HttpOnly
refuse: XSS payloads against others, BeEF
EOF

2. Open Wi-Fi and missing HTTPS — Module 8 again, still not a café capture

If the session cookie or Authorization header rides HTTP without TLS, an observer who is allowed to see that path can copy the secret the same way Module 8 copied YOUR GET on loopback. That is why Secure (cookie sent only on HTTPS) and site-wide HTTPS are the transport fixes, not a quieter sniffer. Open café Wi-Fi is the story students want because the radio feels public. The ethics line did not move: you do not capture other guests. “The café had no password” is not consent to their Cookie headers. “I needed to see a real session” is not consent. Your real session is one you caused on 127.0.0.1 or on an app you own, under HTTPS you control. Leftover http:// on a login or cookie path you ship is a finding. Hunting leftover HTTP in a hotel to steal strangers is a crime-shaped homework idea this course will fail.

Mixed content (HTTPS page loading HTTP subresources) can still leak. So can a token in a URL that then appears in a Referer to a third party. So can a proxy or “SSL inspection” you did not agree to on a device that is not yours — you do not MITM a roommate to “demonstrate sniffing.” Module 8 already refused fake CAs. This lesson only adds: the thing you were afraid of sniffing is often the session secret. Encryption of the application data is still the fix. A VPN may hide inner destinations from the café clerk; it does not replace HTTPS to the site; it does not authorize sniffing other people. Write two columns: leak (cleartext session) versus fix (HTTPS + Secure). Do not fill the leak column with a pcap of the floor.

3. Missing flags, fixation, shared glass — copies that keep working

SameSite is not HTTPS and not HttpOnly. It is a rule about when the browser attaches the cookie to cross-site requests (a click from another origin, an embedded form). Lax/Strict shrink a class of cross-site request forgery that rides a cookie the browser already has. SameSite=None requires Secure. Missing SameSite on an old browser default is a named gap, not a CSRF exploit kit against a live bank. Short TTL and idle timeout shrink the window if a value is copied. Predictable ids shrink the work to guess. Session fixation: the attacker wants the victim to log in without the server minting a fresh id, so a known pre-login id becomes an authenticated id. The fix is rotate the session id at login — a server change, not a homework attack on a classmate. Physical access: unlocked laptop, “remember me,” a shared family browser. Log out. Lock the screen. Revoke on password change.

None of these paths needs a proof-of-concept against a stranger to be teachable. If a blog titled with a cert acronym publishes cookie-replay steps, BeEF hooks, or Wireshark filters for Cookie:, that blog is not this course. Skill does not create consent. A public login form is still someone else’s session factory. If you cannot say the token is one you minted on a host you own, you do not touch it. Lesson 4 will mint cookies on 127.0.0.1 or read flags on an app you own. That is the only jar you open.

4. What you record: named paths, matching fixes, refuse line — not a steal plan

Date (UTC). XSS → HttpOnly plus output encoding (no live payload). Cleartext / open Wi-Fi story → HTTPS plus Secure (no café capture). Missing SameSite → Lax/Strict (and None only with Secure). Fixation → rotate id at login. Shared browser → logout and revoke. Ethics: never steal cookies, never XSS a live site, never Wireshark café, never replay a token. Legal: original Cyberlium teaching mapped to the CEH v13 session-hijacking domain — not official EC-Council training, not a cert, not exam dumps. File: $HOME/cyberlium-lab/session-stolen-concepts-notes.txt, chmod 600. Empty files fail. Files that include a payload, a webhook, or someone else’s cookie value fail even if you “did not send it.”

A useful feeling: “I did not pop an account so I did not learn.” That feeling is the leak into unauthorized impersonation. The skill is naming the path and the control. Next lesson writes the flags as a shipping checklist. The lab after that is DevTools or curl on a Set-Cookie YOU sent. Do not add a second origin because localhost felt too kind. Do not paste XSS into a production comment field as “just looking.”

5. Wrong vs right: hijack PoC / café tap vs named leak paths and fixes

Worked failure — same curiosity about stolen sessions, opposite blast radius. Right never needs a victim account when the path has a name and a control.

  • Wrong

    XSS payload against a live shop or school portal. document.cookie to a webhook. Wireshark café Wi-Fi for Cookie headers. Replay a classmate token. BeEF. Session-fixation kit against a roommate. Call it CEH hijacking. This course is not official CEH training and does not give you that hunt.

  • Right

    Name XSS (HttpOnly + encoding), cleartext (HTTPS + Secure), missing SameSite, fixation (rotate at login), shared glass (logout/revoke). Fill session-stolen-concepts-notes.txt, chmod 600. No live XSS. No café. No steal. Next: Cookie Flags and Logout Hygiene.

6. Hands-on: lock session-stolen-concepts-notes.txt — names only, no payload

On a computer you own, create cyberlium-lab if needed. Fill the template in your own words. Do not add an XSS string aimed at a hostname you do not own. Do not add a pcap. chmod 600. The block writes notes and a literacy print — it never opens a socket to a shop and never prints a steal script.

Command guide

Fixation and shared glass — WHAT/WHY then lock

═══ COMMANDS ═══

Command — copy this

cat >> "$NOTES" << 'EOF'
fixation: accept a token the attacker already knows — rotate at login
shared_glass: a borrowed logged-in browser IS the session
refuse: hijack cookbooks
EOF

Mission: session-stolen-concepts-notes.txt in cyberlium-lab (mode 600)

1) Name XSS (HttpOnly + encoding), cleartext (HTTPS + Secure), missing SameSite, fixation (rotate at login), and shared-browser revoke — no payloads. 2) Fill $HOME/cyberlium-lab/session-stolen-concepts-notes.txt and chmod 600. 3) Ethics: no live XSS, no stolen cookies, no café Wireshark, no token replay.

Stuck? Ask Cyberlium AI Mentor

If “I cannot learn hijacking without a PoC against a live login” still feels true, ask for a hint — not a steal recipe. Try: "Hint only: why XSS plus a non-HttpOnly cookie is a named leak, why café Wireshark is still out, why HTTPS and flags are the fixes, and where locked session-stolen-concepts-notes.txt lives?" You still fill the file. No payload. No café. No BeEF.

You now name how session secrets leak — XSS without HttpOnly, cleartext on a path you should have encrypted, flags never set, ids that survive login, glass you left unlocked — without running a hijack kit. Notes are locked in cyberlium-lab. This is original Cyberlium teaching mapped to the CEH v13 session-hijacking domain — not official EC-Council training, not a cert, not exam dumps. Next — Cookie Flags and Logout Hygiene — writes Secure, HttpOnly, SameSite, short TTL, and revoke-on-password-change as the shipping list, still without a steal.

Knowledge Check

1

APPLY: A teammate wants to paste an XSS payload into a live shop search box “to steal session cookies for CEH.” What is the named path, and what do you do?

Multiple choice

Knowledge Check

2

APPLY: True or False: Open café Wi-Fi makes other guests’ session cookies in-scope, because Module 11 is session hijacking and Module 8 was sniffing.

True or False

Knowledge Check

3

APPLY: Which pairing matches this lesson’s artifact and the next lesson?

Multiple choice

Knowledge Check

4

APPLY: curl of http://192.168.0.1/ shows a home router login (TP-Link / Netgear / Huawei / "Router Admin"). Is that DEMO in scope as a hacking target?

Multiple choice

← Previous

Answer all 4 knowledge checks to continue. (0/4 answered)