Skip to content
Misconfiguration Disclosed report Advanced CVE-2026-6768

Cookie `__Host-Http-` Prefix Validation Bypass (HttpOnly Requirement Defeated)

Firefox's cookie prefix validation checks prefixes in array order and returns on the first match, so a cookie named with the __Host-Http- prefix is validated against the weaker __Host- rules and the HttpOnly requirement is never enforced. A server that omits HttpOnly on such a cookie would have it accepted and readable from JavaScript, so a session token could be stolen through XSS.

Satoki Tsuji Follow

Originally disclosed on Mozilla

  • Fixed in 11 days
  • Paid in 16 days
  • Disclosed after 11 days

Created attachment 9553337 poc_server.py

Summary

A prefix matching order bug in Firefox's CookiePrefixes::Check() causes cookies with the __Host-Http- prefix to be validated against the weaker __Host- rules instead of the intended __Host-Http- rules, bypassing the HttpOnly attribute requirement.

Affected Files

  • netwerk/cookie/CookiePrefixes.cpp (lines 19-96)
  • netwerk/cookie/CookieValidation.cpp (line 159)

Root Cause

The gCookiePrefixes array defines prefixes in the following order:

Index Prefix Validation Requirements
0 __Secure- Secure attribute
1 __Host- Secure + no Domain + Path=/
2 __Http- Secure + HttpOnly
3 __Host-Http- Secure + HttpOnly + no Domain + Path=/

The Check() function iterates through the array and returns on the first match:

C++
bool CookiePrefixes::Check(const CookieStruct& aCookieData, bool aSecureRequest) {
  for (CookiePrefix& prefix : gCookiePrefixes) {
    if (StringBeginsWith(aCookieData.name(), prefix.mPrefixCString,
                         nsCaseInsensitiveCStringComparator)) {
      return prefix.mCallback(aCookieData, aSecureRequest);  // returns on first match
    }
  }
  return true;
}

For a cookie named __Host-Http-token:

  1. __Secure- — no match
  2. __Host- — MATCHES — __Host- validation executed (does NOT check HttpOnly)
  3. __Http- — never reached
  4. __Host-Http- — never reached

The __Host-Http- validation (which requires HttpOnly) is completely bypassed.

Secondary Issue: Case-Insensitive Matching

Code comments state "case-sensitive match" but the implementation uses nsCaseInsensitiveCStringComparator:

C++
// Comment: "If a cookie's name begins with a case-sensitive match for the string..."
// Code: nsCaseInsensitiveCStringComparator  ← case-INSENSITIVE

RFC 6265bis explicitly requires case-sensitive prefix matching.

Reproduction Steps

  1. Run poc_server.py (or double-click poc_test.bat on Windows)
  2. Open https://localhost:4443/ in Firefox
  3. Accept the self-signed certificate warning
  4. Observe the results on the page

Expected Behavior (Fixed)

Server sends:

Set-Cookie: __Host-Http-token=SECRET_VALUE; Secure; Path=/

The __Host-Http- prefix requires the HttpOnly attribute. Since HttpOnly is absent, this cookie should be rejected.

Actual Behavior (Bug)

The cookie is accepted and readable via document.cookie in JavaScript.

Exploit Scenarios

Scenario 1: Security Guardrail Bypass

When a developer uses the __Host-Http- prefix but a server-side bug causes the HttpOnly flag to be omitted:

  • Expected: Browser rejects the cookie, preventing misconfiguration
  • Actual: Firefox accepts the cookie, making it readable by JavaScript
  • Impact: Session tokens become vulnerable to XSS-based theft
Attacker → XSS injection → document.cookie → steals __Host-Http-session token

Scenario 2: Cross-Browser Behavior Divergence

  1. Attacker performs MITM and strips HttpOnly from a __Host-Http- cookie
  2. Compliant browsers (Chrome, etc.) reject the cookie
  3. Firefox accepts it → JavaScript can access the cookie
  4. Attacker's XSS payload exfiltrates the cookie to an external server

Scenario 3: Case-Insensitive Prefix Bypass

Set-Cookie: __host-http-token=secret; Secure; Path=/

RFC-compliant browsers do not treat this as a prefixed cookie (lowercase). Firefox matches case-insensitively, so __Host- validation is applied but __Host-Http- validation is still unreachable.

Severity Assessment

sec-high — Cookie prefixes are security guardrails. This bug defeats the intended protection of the __Host-Http- prefix, potentially enabling cookie theft via XSS in scenarios where the prefix was relied upon to enforce HttpOnly.

The __Http- and __Host-Http- prefixes are standardized in the IETF draft-ietf-httpbis-rfc6265bis and are always enabled in Firefox (no pref gate). Web Platform Tests exist for these prefixes under testing/web-platform/tests/cookies/prefix/.

Suggested Fix

Option A: Reorder the array (simplest)

Place longer prefixes first:

C++
gCookiePrefixes[] = {
  __Host-Http-  // index 0 (longest match first)
  __Host-       // index 1
  __Http-       // index 2
  __Secure-     // index 3
};

Option B: Longest-match algorithm

Scan all prefixes and apply validation for the longest matching prefix.

Option C: Fix case sensitivity

Remove nsCaseInsensitiveCStringComparator to use default case-sensitive comparison (RFC 6265bis compliant).

The original report as published on Mozilla's Bugzilla, by Satoki Tsuji. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The prefix list is ordered so that the shorter __Host- prefix is tested before the longer __Host-Http- prefix, and Check() returns on the first match, so the stricter validation is unreachable.

Impact

A cookie that should have been rejected for lacking HttpOnly is accepted and readable via document.cookie, so session tokens could be stolen through XSS; the report also notes a case-insensitive matching divergence from other browsers.

What the attacker needed

Firefox browser; Server sets a __Host-Http- cookie without HttpOnly; Attacker can run script on the site (XSS)

The fix

The prefix list should be reordered so longer prefixes are matched first, or the check should apply the longest matching prefix, and the comparison should be made case-sensitive.

How it was found

  1. Run the provided proof-of-concept server.
  2. Open the local HTTPS page in Firefox.
  3. Accept the self-signed certificate warning.
  4. Observe the results shown on the page.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Browsers support special cookie name prefixes that act as safety rules: if a cookie starts with a given prefix, the browser refuses to store it unless it also has certain attributes. Here the browser checked the rules in the wrong order, so a stricter prefix was treated as a looser one and a required protection flag was never checked. That means a cookie the browser should have thrown away was kept and could be read by scripts on the page.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More by Satoki Tsuji

View all

8 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.