← New search

Other meanings of Session hijacking

Computer Security

Session hijacking

Session hijacking is a computer security attack in which an attacker takes over a valid user session by stealing or predicting the session identifier, thereby gaining unauthorized access to the victim's authenticated web application or network service. The attack exploits the stateless nature of HTTP, where each request must be tied to a session token, typically stored in a cookie, URL parameter, or hidden form field. By obtaining this token, the attacker can impersonate the legitimate user without needing their credentials. Session hijacking is a subset of identity spoofing and is closely related to man-in-the-middle attacks, cross-site scripting, and session fixation. It poses a significant threat to online banking, e-commerce, and any service that relies on session-based authentication. Mitigations include using HTTPS, secure cookie flags, session timeouts, and token binding.

~1 in 5
Web attacks involve session hijacking or related flaws
Proportion of web attacks involving session issues
2011
Year of the Firesheep extension release
Year Firesheep was released
RFC 6265
Defines HTTP state management (cookies)
RFC defining cookies
1

Mechanisms and attack vectors

Session hijacking typically begins with the theft of a session identifier, which can be accomplished through several vectors. Network sniffing is the most direct method: on an unencrypted Wi-Fi network, an attacker can capture HTTP traffic and extract session cookies transmitted in plaintext. Tools like Firesheep, released in 2010, demonstrated this vulnerability by automating cookie capture on public networks, prompting widespread adoption of HTTPS. Cross-site scripting (XSS) is another common vector, where an attacker injects malicious script into a trusted website to read the victim's cookies and send them to an external server. Session fixation is a related attack where the attacker sets a known session ID in the victim's browser before authentication, then waits for the victim to log in, after which the attacker uses the same ID. Additionally, predictable session IDs can be guessed if the server uses weak random number generation; for example, early PHP session IDs were derived from the system time, making them brute-forceable. Finally, man-in-the-middle attacks, such as SSL stripping, can downgrade HTTPS to HTTP, allowing cookie interception.

2

Consequences and impact

The impact of session hijacking ranges from privacy breaches to financial fraud. An attacker who hijacks a session can perform any action the legitimate user is authorized to do, such as transferring funds, changing passwords, or accessing sensitive data. In enterprise environments, hijacking an administrator session can lead to full system compromise, data exfiltration, and ransomware deployment. The 2011 attack on the RSA SecurID tokens, though not a classic session hijack, highlighted the cascading effects of credential theft. In the healthcare sector, session hijacking can violate HIPAA regulations, leading to fines and loss of patient trust. The OWASP Top Ten has consistently listed broken authentication and session management as a critical risk. Real-world incidents include the 2015 TalkTalk breach, where session hijacking was used to access customer data. Moreover, session hijacking is often a precursor to account takeover fraud, which cost businesses billions annually. The psychological impact on victims includes identity theft and long-term credit damage.

3

Defenses and countermeasures

Defending against session hijacking requires a multi-layered approach. The most fundamental measure is to use HTTPS with HSTS (HTTP Strict Transport Security) to encrypt all traffic and prevent cookie interception. Setting the Secure and HttpOnly flags on cookies ensures they are only sent over HTTPS and are inaccessible to JavaScript, mitigating XSS-based theft. Implementing session timeouts and idle expiration reduces the window of opportunity. Session rotation — regenerating the session ID after login and periodically — limits the usefulness of a stolen token. Token binding ties the session to the client's TLS certificate, making it unusable elsewhere. Multi-factor authentication adds an extra layer, though it does not prevent session hijacking if the session token is stolen. Web application firewalls can detect anomalous session usage, such as a session ID being used from two different IP addresses. Additionally, user education about phishing and public Wi-Fi risks is essential. The OWASP Session Management Cheat Sheet provides comprehensive guidelines for developers.

4

Lesser-known aspects

Beyond the well-known vectors, session hijacking has several niche dimensions. Session prediction was a significant issue in the 1990s when many web servers used sequential or time-based session IDs; the Apache server's mod_usertrack module was vulnerable to such attacks. Session hijacking in non-HTTP protocols is also possible: for example, TCP session hijacking involves predicting the sequence number to inject packets into an established connection, a technique demonstrated by Kevin Mitnick in 1994. Mobile applications are susceptible to session hijacking through insecure storage of session tokens on devices. Cloud-based services face unique risks, as session tokens may be shared across microservices. The HTTP/2 protocol introduced multiplexing, which can complicate session tracking but also offers new attack surfaces. Session hijacking via browser extensions is a growing concern, as malicious extensions can read cookies from all sites. Finally, session awareness is a concept in network security where the state of a session is monitored to detect anomalies, but it is often overlooked in favor of simpler defenses.

Glossary

Session ID
A unique identifier assigned to a user's session, typically stored in a cookie.
Cross-site scripting (XSS)
A vulnerability that allows attackers to inject client-side scripts into web pages viewed by other users.
Session fixation
An attack where the attacker sets a known session ID in the victim's browser before authentication.
HSTS
HTTP Strict Transport Security, a web security policy that forces browsers to use HTTPS.
Token binding
A mechanism that cryptographically binds a session token to the client's TLS certificate.

Session hijacking remains a critical threat in web security, evolving with new technologies and attack vectors.