Cookie per host quota enforcement is off by one
Categories
(Core :: Networking: Cookies, defect, P3)
Tracking
()
People
(Reporter: dveditz, Assigned: tannal2409)
References
(Blocks 1 open bug)
Details
(Keywords: good-first-bug, Whiteboard: [necko-triaged])
Attachments
(1 file, 1 obsolete file)
In CookieCommons.h we define kCookieQuotaPerHost = 150;
, but after a purge we have 151 cookies left. To trigger a purge we have to have 181 cookies, but that appears intended because we define kMaxCookiesPerHost = 180;
STR:
- pick a domain you don't care about, like https://example.org, and clear all it's cookies
- in the DevTools console on that site run
for (i = 1; i <= 181; i++) document.cookie = `c${String(i).padStart(3,0)}=0`;
document.cookie.split(';').length
Expected result: 150
Actual result: 151
Being off by one isn't that big a deal because the quota is more of a suggestion in the spec. But we differ from Chrome and that might have unwanted effects on some site someday.
Reporter | ||
Updated•2 years ago
|
Reporter | ||
Comment 1•2 years ago
|
||
In CookieStorage.cpp when we go to add our 181st cookie we find that we already have kMaxCookiesPerHost (180) stored
https://searchfox.org/mozilla-central/rev/50588a0b728b365afdd298debd35e8302efe7850/netwerk/cookie/CookieStorage.cpp#535
So we calculate how many cookies we ought to delete and get 180-150 = 30:
uint32_t limit = mMaxCookiesPerHost - mCookieQuotaPerHost;
So we delete that many and are left with the expected 150 cookies for that host. But remember we were in the middle of adding a cookie when we checked the quotas. So now we add that new cookie and end up with 151.
Comment 2•2 years ago
|
||
Should be trivial to fix. @Dylan?
Assignee | ||
Comment 3•4 months ago
|
||
Updated•4 months ago
|
Assignee | ||
Comment 4•4 months ago
|
||
Assignee | ||
Updated•4 months ago
|
Updated•4 months ago
|
Updated•4 months ago
|
Comment 5•2 months ago
|
||
This good-first-bug hasn't had any activity for 2 months, it is automatically unassigned.
For more information, please visit BugBot documentation.
Thanks for your work on this tannel,
Anything I can do to help this along?
Updated•2 months ago
|
Assignee | ||
Comment 7•2 months ago
|
||
Hi, I updated the revision, please take a look again when you have a moment.
I finally got that trick test pass.
Thank you for reminding me about this bug.
Assignee | ||
Comment 8•2 months ago
|
||
(In reply to edgul from comment #6)
Thanks for your work on this tannel,
Anything I can do to help this along?
I have a few questions:
- Should I add new tests for these changes?
- Where should I add them?
- How should I implement them?
Assignee | ||
Updated•2 months ago
|
The coverage we have looks sufficient. Just need to make sure all the exiting tests pass in a way that maintains their integrity. I'll review your patch again.
Description
•