Someone Logs In. Then Someone Else Takes Over.
Your customer logs into your website. They authenticate with their username and password. Everything looks normal. But somewhere on the network — or through a vulnerability in your application — an attacker has stolen the session token that identifies your customer as logged in. Now the attacker is inside your application, browsing as your customer, with full access to their account.
This is session hijacking. It's one of the most impactful web security vulnerabilities, and it's more common than most business owners realise.
How Sessions Work
When a user logs into a website, the server generates a session token — essentially a long, random string of characters — and sends it to the user's browser, typically as a cookie. From that point on, every request the browser makes includes that token, and the server uses it to recognise the user without requiring them to re-enter their password on every page.
If an attacker gets hold of that token, they can present it to the server themselves. The server has no way of knowing it's not the real user.
How Attackers Steal Session Tokens
Cross-Site Scripting (XSS)
This is the most common route. If an attacker can inject malicious JavaScript into your web pages — through an XSS vulnerability — that script can read the user's session cookie and send it to the attacker's server. Once received, the attacker has a valid session they can use from anywhere.
Network Interception (Man-in-the-Middle)
On unencrypted HTTP connections, session cookies travel as plain text. Anyone on the same network — particularly a shared Wi-Fi network — can read them. This is less common now that HTTPS is widespread, but any site still serving pages over HTTP is vulnerable.
Session Fixation
A subtler attack. Instead of stealing an existing session token, the attacker sets the session token themselves — they trick the user into authenticating with a token the attacker already knows. After login, the attacker uses that pre-known token to access the account.
Cookie Theft via Subdomain Vulnerabilities
If a subdomain of your site (like `old.yoursite.co.uk`) is compromised or vulnerable, an attacker may be able to set cookies that apply to your main domain. Proper cookie scoping is essential.
What Makes Sites Vulnerable
Several common misconfigurations make session hijacking easier:
**Missing HttpOnly flag** — The `HttpOnly` attribute on a cookie prevents JavaScript from reading it. Without it, any XSS vulnerability immediately becomes a session hijacking opportunity.
**Missing Secure flag** — The `Secure` attribute ensures the cookie is only sent over HTTPS. Without it, the cookie can be transmitted over plain HTTP.
**Missing SameSite attribute** — The `SameSite` attribute controls when cookies are sent with cross-site requests. Without proper configuration, cookies may be sent in contexts they shouldn't be, enabling cross-site request forgery attacks that abuse an active session.
**Long or non-expiring sessions** — Sessions that never expire give attackers a large window to use stolen tokens.
**Predictable session tokens** — Session tokens must be cryptographically random. Tokens generated with weak randomness can sometimes be predicted or brute-forced.
The Real-World Impact
Session hijacking attacks on customer accounts lead to account takeover — one of the most damaging outcomes for any web business. An attacker with access to a customer account can change email addresses and passwords (locking the real customer out), make purchases or bookings, access saved payment methods, harvest personal data, and use the account to attack others.
Under UK GDPR, an account takeover that exposes personal data is a reportable data breach. You may have 72 hours to notify the ICO.
How a Penetration Test Catches These Issues
A web application penetration test specifically looks for session management weaknesses. This includes checking cookie attributes (`HttpOnly`, `Secure`, `SameSite`), testing whether session tokens are regenerated after login (preventing fixation), verifying session expiry behaviour, scanning for XSS vulnerabilities that could be used to steal tokens, and checking that tokens are sufficiently random and long.
Automated security scanning — as offered by Yrzo AI — covers all of these checks and reports exactly which cookies are missing which flags, making remediation straightforward.
Fixing Session Vulnerabilities
Most session security issues are configuration problems rather than complex code changes. Setting `HttpOnly`, `Secure`, and `SameSite=Strict` on session cookies takes minutes. Regenerating session IDs after login is a one-line change in most frameworks. Enforcing short session expiry is a server-side configuration.
The challenge is knowing which of these you're missing — which is exactly what a security scan tells you.
Find out if your website has these vulnerabilities
Yrzo AI runs 110+ automated security checks and delivers a full report in under 20 minutes. Starting from £149.
Scan your website →