enforce __Host- and __Secure- cookie name prefixes in CookieJar#13168
enforce __Host- and __Secure- cookie name prefixes in CookieJar#13168arshsmith1 wants to merge 1 commit into
Conversation
323a380 to
8adb72b
Compare
8adb72b to
ca86660
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13168 +/- ##
=======================================
Coverage 98.97% 98.97%
=======================================
Files 131 131
Lines 48824 48856 +32
Branches 2546 2552 +6
=======================================
+ Hits 48324 48356 +32
Misses 376 376
Partials 124 124
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Merging this PR will not alter performance
Comparing Footnotes
|
What do these changes do?
CookieJar.update_cookiesstores cookies from a response without ever looking at the__Secure-/__Host-name prefixes defined in RFC 6265bis §4.1.3. Those prefixes exist so a server can trust that a cookie it sees really was set over HTTPS, host-locked (for__Host-), and with theSecureattribute. A sibling subdomain or an on-path party can currently forge one: sendingSet-Cookie: __Host-sid=attacker; Domain=example.com; Path=/fromsub.example.comgets stored as a domain cookie and later sent to the apexhttps://example.com/, which is the opposite of the host-only guarantee. A browser rejects that cookie outright.The check now lives inside
update_cookies, right where the incoming morsel is available: a name that case-insensitively begins with__Secure-or__Host-is dropped unless it arrived over a secure origin with theSecureattribute, and__Host-additionally requires host-only (noDomain) withPath=/. Cookies seeded programmatically (no response host) are untouched.Are there changes in behavior for the user?
A
__Secure-/__Host-cookie that doesn't meet the prefix requirements is no longer accepted into the jar, matching browser behavior. Compliant cookies and all cookies without those prefixes are unaffected.Is it a substantial burden for the maintainers to support this?
No. It is a self-contained guard in one method plus a small
_is_secure_originhelper that mirrors the secure-origin logicfilter_cookiesalready uses.Related issue number
N/A
Checklist
CONTRIBUTORS.txtCHANGES/folder