v140 ยท miscellaneous
Http cookie prefix
There are cases where it's important to distinguish on the server side between cookies that were set by the server and ones that were set by the client. One such case is cookies that are normally always set by the server, unless some unexpected code (an XSS exploit, a malicious extension, a commit from a confused developer, etc.) happens to set them on th
concepts
-
Cookie Prefix
__Http- cookie name prefix โ server-asserted invariants on the cookie. The browser enforces HttpOnly + Secure + Path=/ regardless of the cookie's actual attributes.
-
XSS Attempt
The XSS motivation in action: trigger a malicious
document.cookiewrite against a__Http-cookie and watch the browser reject it while the unprotected cookie gets clobbered. -
Prefix Comparator
The full matrix:
__Secure-,__Host-, and__Http-side by side. Which attributes each prefix requires, forbids, or leaves free, plus JS readability. -
Header Inspector
Paste raw
Set-Cookieheaders and the inspector validates them against all three prefixes plus SameSite/Secure sanity. Triage tool for misbehaving cookie jars. -
Attack Walkthrough
Step-by-step XSS scenario where the attacker tries to overwrite the session cookie. Toggle between unprefixed,
__Secure-, and__Http-and see exactly which step finally stops the attack.
why it shipped
Server operators need to ensure that certain cookies that they receive were indeed set by them, and not by a malicious/compromised script.