RESOLVED FIXED322546
[CFNetwork] Honor Expires cookie dates that use JS Date.toString() dates (month-before-day Expires values)
https://bugs.webkit.org/show_bug.cgi?id=322546
Summary [CFNetwork] Honor Expires cookie dates that use JS Date.toString() dates (mon...
Brent Fulgham
Reported 2026-08-25 16:50:20 PDT
CFNetwork's cookie-date parser rejects a cookie-date containing a parenthesized timezone comment, which is exactly the format JavaScript's Date.prototype.toString() produces. The Expires attribute is silently ignored, so a cookie the site meant to be persistent is stored as a session cookie and disappears when the browser quits. RFC 6265 section 5.1.1 requires this to parse: "(", ")" and "-" are all delimiters, since they fall in the %x20-2F range, so the comment is consumed as a run of delimiters. "Thu Apr 10 1980 16:33:12 GMT-0700 (Pacific Daylight Time)" tokenizes to Thu / Apr / 10 / 1980 / 16:33:12 / GMT / 0700 / Pacific / Daylight / Time, and the first match for each of found-time, found-day-of-month, found-month and found-year all succeed. Chrome parses it cleanly. Writing document.cookie = "session=" + token + ";expires=" + someDate + ";path=/" with someDate from toString() rather than toUTCString() is a common pattern, so on Safari those logins silently fail to survive a restart while the same site works elsewhere.
Attachments
Radar WebKit Bug Importer
Comment 1 2026-08-25 16:50:34 PDT
Brent Fulgham
Comment 2 2026-08-25 17:03:27 PDT
Brent Fulgham
Comment 3 2026-08-26 10:30:14 PDT
Further testing revealed that the real issue was not parenthesized comments. The true issue was that CFNetwork date parsing rejects dates in "Month First" order. When these dates are used with document.cookie, the cookie expiry silently becomes a session cookie.
EWS
Comment 4 2026-08-27 22:06:58 PDT
Committed 320016@main (d01d085ea0fd): <https://commits.webkit.org/320016@main> Reviewed commits have been landed. Closing PR #72457 and removing active labels.
Brent Fulgham
Comment 5 2026-08-28 09:57:24 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/62280
Note You need to log in before you can comment on or make changes to this bug.