Cookie Poisoning
What is Cookie Poisoning?
Cookie PoisoningAn attack that modifies the contents of HTTP cookies before they are sent back to a web application, in order to alter trust, identity, or business logic decisions.
Cookie poisoning targets cookies that carry application state — user IDs, roles, prices, tenant selectors, feature flags, or tokens — and tampers with them before they return to the server. If the server trusts the cookie without verifying integrity, the attacker can escalate privilege, change a cart total, switch tenant, or bypass authorization. Attackers edit cookies directly in their own browser (DevTools), inject them via cross-site scripting, or alter them in transit via a man-in-the-middle on an unencrypted link. The flaw maps to OWASP's A01:2021 Broken Access Control and A08:2021 Software and Data Integrity Failures.
Signing is necessary but not sufficient. A known or guessable secret key turns a signed cookie into a forgeable one — against Flask's signed client-side sessions, tools like flask-unsign brute-force weak SECRET_KEY values to mint arbitrary sessions. Algorithm-confusion against JWT cookies (accepting alg: none, or verifying an RS256 token with the public key treated as an HMAC secret) similarly lets attackers rewrite claims. Padding-oracle and CBC bit-flipping attacks (e.g. ASP.NET's 2010 Padding Oracle, CVE-2010-3332) targeted encrypted-but-unauthenticated cookies.
Defences: keep sensitive state server-side; if stored client-side, use authenticated encryption or HMAC with a strong secret and pinned algorithm; validate every value server-side; and set Secure, HttpOnly, SameSite, and __Host- prefixes over TLS.
flowchart LR
A[Attacker edits cookie<br/>role=user -> role=admin] --> R[HTTP request<br/>with tampered cookie]
R --> S{Server verifies<br/>integrity?}
S -->|No| E[Privilege escalation<br/>price/tenant bypass]
S -->|Yes HMAC/AEAD| D[Reject / detect tampering]● Examples
- 01
A user edits a cookie role=user to role=admin and gains access to administrative pages because the server doesn't verify integrity.
- 02
An e-commerce site stores price in a cookie; an attacker changes it before checkout to pay one cent for an item.
● Frequently asked questions
What is Cookie Poisoning?
An attack that modifies the contents of HTTP cookies before they are sent back to a web application, in order to alter trust, identity, or business logic decisions. It belongs to the Attacks & Threats category of cybersecurity.
What does Cookie Poisoning mean?
An attack that modifies the contents of HTTP cookies before they are sent back to a web application, in order to alter trust, identity, or business logic decisions.
How do you defend against Cookie Poisoning?
Defences for Cookie Poisoning typically combine technical controls and operational practices, as detailed in the full definition above.