Bypassing WAFs with the phantom $Version cookie

Executive Summary

The article explains how legacy cookie attributes such as $Version can be used to craft Cookie headers that confuse modern parsers and bypass web application firewalls. The author demonstrates that frameworks like Spring Boot, Apache Tomcat, and Python’s SimpleCookie accept $Version-prefixed cookies and unescape backslashes, enabling attackers to hide malicious payloads in quoted strings. The research claims that many WAFs, including AWS WAF, fail to detect these crafted headers, potentially allowing SQL injection or command injection attacks. Defensive guidance includes validating and normalizing cookie headers, rejecting legacy attributes, and updating WAF rules to account for quoted cookie values and legacy parsing behavior.

Original Overview

HTTP cookies often control critical website features, but their long and convoluted history exposes them to parser discrepancy vulnerabilities. In this post, I'll explore some dangerous, lesser-known features of modern cookie parsers and show how they can be abused to bypass web application firewalls. This is the first part of a series of blog posts on cookie parsing. There have been many attempts to standardize HTTP cookies, starting with the first official standard: RFC2109 . Even though modern browsers do not support legacy RFCs, many web servers still do. Here's an example valid Cookie header: $Version is a required attribute, identifying the version of the state management specification to which the cookie conforms. Other interesting attributes include $Domain and $Path , which...