Fix cookies expiring at the Unix epoch - #13692
Draft
Str0k wants to merge 2 commits into
Draft
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13692 +/- ##
=======================================
Coverage 99.03% 99.03%
=======================================
Files 135 135
Lines 50940 50971 +31
Branches 2677 2678 +1
=======================================
+ Hits 50446 50477 +31
Misses 370 370
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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What do these changes do?
Treat a parsed cookie expiration of
0as a valid timestamp. The existing truthiness check interpretsThu, 01 Jan 1970 00:00:00 GMTas a parse failure, clears the Expires attribute, and retains the cookie. Checkingis not Nonelets the existing expiration machinery remove it.Two regression cases cover receiving an already-expired cookie and replacing an existing cookie. A local HTTP test sets a cookie, expires it, then verifies the next request sends only an unaffected control cookie. All three cases fail before the fix.
Are there changes in behavior for the user?
Cookies with Expires exactly at the Unix epoch are removed and are no longer sent in subsequent requests. Invalid dates still follow the existing fallback. This is an expiration correctness fix; no vulnerability severity is claimed.
Is it a substantial burden for the maintainers to support this?
The change is one explicit sentinel check in the existing expiration path, with regression coverage and no new API or dependency.
Related issue number
No existing report for this timestamp-zero case was found in the issue/PR searches. Historical #4066 addressed a different expired-cookie scheduling problem.
Checklist
CONTRIBUTORS.txtCHANGES/folderLocal validation and limitations
Windows, Python 3.12.10, pure Python aiohttp, base
5da6d53032d59a08faeba2fab96361864c817faa.Before the fix:
After the fix:
The skipped tests require POSIX permission bits. Black 26.5.1, isort 9.0.1 and flake8 7.3.0 pass for the three changed Python files. Mypy with
--follow-imports=silentpasses for those files. Without that flag, mypy reports 16 diagnostics in four other imported modules, including platform-specific Gunicorn/Windows issues; a complete project type-check is not claimed. Cython extensions were not built; this changes CookieJar expiration dispatch, not the HTTP or WebSocket parsers.Drafted with Codex (GPT-6); human review pending from @Str0k. Kept in draft as required by AGENTS.md.