Repository navigation
Add limits for client cookie handling - #13930
Conversation
Co-authored-by: J. Nick Koston <nick@koston.org>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13930 +/- ##
==========================================
+ Coverage 99.06% 99.09% +0.03%
==========================================
Files 135 135
Lines 52582 53491 +909
Branches 2739 2806 +67
==========================================
+ Hits 52092 53009 +917
+ Misses 369 363 -6
+ Partials 121 119 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
|
Agreed. Finding dropped. Subclass load() path stays as is. |
|
|
these are unrealistic and browsers drop it without a log, decline |
decline, another check for a crazy edge case doesn't justify the performance hit just to log garbage |
Accepted. Attribute-cap logging dropped. Matches browser behaviour. |
Accepted. No size check in |
|
|
|
performance is fixed now. I've cleaned it up as much as I think I can. want to sleep on it and look at it with fresh eyes though Its just bigger than I would like, but a limit, validation, and eviction system for cookies was already going to be big |
|
A structurally better design would be keep containers in sync by storing things that cannot be allowed out of sync in the same container but its probably way to big to put in this PR and than we have to go get the performance right on that again, and I couldn't come up with a design that didn't make this PR 1000 lines longer and was performant. Too much mitigate risk, so going to put that on the shelf as its a larger refactor down the road when we want it |
|
I'm just going to add consistency tests instead as thats the right call to make sure the containers are never out of sync without massively expanding scope |
Consistency test landed in |
PR Review — Add limits for client cookie handlingMerge-ready. The only new commit, What's good:
Findings and earlier dispositions:
Checklist
ℹ️ Triage summary2 pre-existing finding(s) on unchanged code suppressed (freeze). Silent Failure Analysis
🟡 **1. MEDIUM** — trusted caller input silently dropped
|
|
All good on the second Home Assistant instance |
|
Greptile's complaint about threat model being removed is not an issue as it was removed per maintainer request and will be added in a followup pr |
Backport to 3.15: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply b1f6c87 on top of patchback/backports/3.15/b1f6c87b2bd3bd80f2b6c22ff46e11d00921e412/pr-13930 Backporting merged PR #13930 into master
🤖 @patchback |

What do these changes do?
Add limits to client cookie handling. Each
Set-Cookiefield now produces exactly one cookie, as browsers do, andCookieJarcaps how many cookies it stores and how large aCookieheader it builds. Eviction follows Firefox, so expired and non secure cookies go first, least recently used first.Are there changes in behavior for the user?
The jar applies these limits:
Set-Cookiefields per response, 32 attributes per field;Cookierequest header.Extra
name=valuepairs after the first one in aSet-Cookiefield are now ignored instead of becoming separate cookies; see the breaking fragment. Cookies passed withcookies=and an explicitCookieheader are not limited.Is it a substantial burden for the maintainers to support this?
No, the limits are private constants and there is no new public API.
Related issue number
N/A
Checklist
CONTRIBUTORS.txtCHANGES/foldername it
<issue_or_pr_num>.<type>.rst(e.g.588.bugfix.rst)if you don't have an issue number, change it to the pull request
number after creating the PR
.bugfix: A bug fix for something the maintainers deemed animproper undesired behavior that got corrected to match
pre-agreed expectations.
.feature: A new behavior, public APIs. That sort of stuff..deprecation: A declaration of future API removals and breakingchanges in behavior.
.breaking: When something public is removed in a breaking way.Could be deprecated in an earlier release.
.doc: Notable updates to the documentation structure or buildprocess.
.packaging: Notes for downstreams about unobvious side effectsand tooling. Changes in the test invocation considerations and
runtime assumptions.
.contrib: Stuff that affects the contributor experience. e.g.Running tests, building the docs, setting up the development
environment.
.misc: Changes that are hard to assign to any of the abovecategories.
Make sure to use full sentences with correct case and punctuation,
for example:
Use the past tense or the present tense a non-imperative mood,
referring to what's changed compared to the last released version
of this project.
Local test run
Drafted with Claude Opus 5.5; reviewed by @bdraco.