Vulnerability Fixation
Cookie Injection Attack

What are Cookies & a Cookie Injection Attack?

Cookies are small data files sent by a web server to a browser to track user activity or maintain sessions. Each time the user revisits or navigates the site, the browser sends the cookie back, allowing the server to identify and remember the user.

In cookie injection attack, hackers steal or manipulate cookies to gain unauthorized access to sensitive data. Using methods like SQL Injection or Cross-Site Scripting (XSS), attackers can read or modify cookies stored in cleartext, Base64, or hashed formats to inject malicious queries.

Attack

Cookie injection/stealing: attackers use XSS, SQLi, or other flaws to read, modify, or forge cookies (especially those stored in cleartext, Base64, or serialized form) to hijack sessions or inject malicious data.

Impact

Unauthorised account/session takeover, data theft or tampering, impersonation, and broader compromise of application integrity and user privacy.

Solution

Always validate and sanitize cookie-related input on the server.
Set cookie flags: HttpOnly, Secure, SameSite.
Store minimal sensitive data in cookies; use server-side session storage.
Use unpredictable, encrypted/randomized tokens and send cookies via HTTP headers only.

Step - by - Step Video Guide

Also Read :