Cyber Security News

New Cookie Sandwich Technique Let Attackers Bypass HttpOnly Flag On Servers

A newly discovered attack technique, dubbed the “cookie sandwich,” enables attackers to bypass the HttpOnly flag on certain servers, exposing sensitive cookies, including session identifiers, to client-side scripts.

The “cookie sandwich” attack exploits flaws in how web servers parse cookies when special characters, quotes, and legacy attributes are introduced. 

By strategically crafting cookie headers, attackers can manipulate the server’s interpretation of cookie structures, effectively exposing HttpOnly cookies.

Key Mechanisms Of The Attack

Legacy Cookie Parsing: Many web servers support both modern (RFC6265) and legacy (RFC2109) cookie standards. If a cookie header begins with a $Version attribute, servers often default to legacy parsing logic.

Investigate Real-World Malicious Links & Phishing Attacks With Threat Intelligence Lookup - Try for Free

Quoted Strings: Legacy parsing allows quoted strings in cookie values. The parser continues reading until it encounters an unescaped closing quote (“), potentially including unrelated cookies within the quoted value.

Backslash Unescaping: Characters preceded by a backslash (\) are unescaped during parsing, further complicating cookie handling.

Create a cookie sandwich to steal a restricted cookie value
Server interprets

Zakhar Fedotkin, a security researcher at PortSwigger, said if the application reflects the param1 value in its response or lacks proper escaping mechanisms, the entire string—including the sensitive sessionId—can be exposed.

In one proof-of-concept attack, researchers exploited an XSS vulnerability on a vulnerable application running Apache Tomcat:

XSS Injection: JavaScript was injected into an error page due to improper input sanitization.

Cookie Manipulation: The script set $Version, param1, and param2 cookies to create the “sandwich.”

Reflection Exploitation: The manipulated cookies were reflected in a JSON response from a tracking domain, exposing the HttpOnly PHPSESSID cookie.

A crafted request
Server response

Impact And Vulnerable Systems

This vulnerability affects web applications relying on legacy parsing or frameworks that support quoted strings by default (e.g., Python Flask). 

Note that the RFC2109 is supported by default in Apache Tomcat versions 8.5.x, 9.0.x, and 10.0.x.

Hence, this technique leverages XSS, cookie manipulation, and the tracking application’s vulnerability.

The “cookie sandwich” technique underscores the importance of robust cookie security practices and careful handling of legacy compatibility features. 

As attackers continue to exploit overlooked vulnerabilities, organizations must proactively update their systems and adopt modern security standards to safeguard user data.

Integrating Application Security into Your CI/CD Workflows Using Jenkins & Jira -> Free Webinar

Guru Baran

Gurubaran is a co-founder of Cyber Security News and GBHackers On Security. He has 10+ years of experience as a Security Consultant, Editor, and Analyst in cybersecurity, technology, and communications.

Recent Posts

Heathrow and Other European Airports Hit by Cyberattack, Several Flights Delayed

A major cyberattack on a popular aviation software provider has caused significant disruptions at key…

3 hours ago

First-ever AI-powered ‘MalTerminal’ Malware Uses OpenAI GPT-4 to Generate Ransomware Code

AI-powered malware, known as 'MalTerminal', uses OpenAI’s GPT-4 model to dynamically generate malicious code, including…

5 hours ago

Top Zero-Day Vulnerabilities Exploited in the Wild in 2025

The cybersecurity landscape in 2025 has been marked by an unprecedented surge in zero-day vulnerabilities…

6 hours ago

Threat Actors Selling New Undetectable RAT as ’ScreenConnect FUD Alternative’

A threat actor has been observed advertising a new Remote Access Trojan (RAT) on underground…

14 hours ago

BreachLock Named Sample Vendor for PTaaS and AEV in Two New 2025 Gartner® Reports

New York, New York, September 19th, 2025, CyberNewsWire BreachLock, the global leader in offensive security,…

1 day ago

Phishing Attacks Using AI-Powered Platforms to Misleads Users and Evades Security Tools

Phishing campaigns have long relied on social engineering to dupe unsuspecting users, but recent developments…

1 day ago