With Firefox 143, in javascript the command "document.cookie" returns the old value of our cookie
Categories
(Core :: Networking: Cookies, defect)
Tracking
()
People
(Reporter: julien.bittard, Unassigned)
Details
Steps to reproduce:
Our web application generates a cookie to store the CSRF token.
When the login page is displayed, this cookie takes on a new value.
After logging in, the value of this cookie is changed, but our JavaScript code that retrieves the value of this cookie with "document.cookie" systematically returns the old value, not the new one.
Once logged in to the application, if you reload the page via F5, the cookie value is correctly retrieved.
Actual results:
Since the old cookie value is being retrieved, calls to our application's Rest Services are being rejected by the server because the CSRF token value is not correct.
Expected results:
In versions prior to 143, Firefox correctly returned the new cookie value.
Comment 1•1 year ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Privacy: Anti-Tracking' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•1 year ago
|
Could you test on 144 (beta) or 145 (nightly) and see if the problem has been resolved? We recently fixed a bug in this area which could be the same.
If the problem persists, could you provide some more information about your site?
- What kind of request sets the cookie? XHR, fetch, top-level naivigation?
- What are the cookie attributes you are using for the CSRF?
- If you are able to provide your site name, we may be able to take a closer look
| Reporter | ||
Comment 3•1 year ago
|
||
(In reply to edgul from comment #2)
Could you test on 144 (beta) or 145 (nightly) and see if the problem has been resolved? We recently fixed a bug in this area which could be the same.
If the problem persists, could you provide some more information about your site?
- What kind of request sets the cookie? XHR, fetch, top-level naivigation?
- What are the cookie attributes you are using for the CSRF?
- If you are able to provide your site name, we may be able to take a closer look
Hi,
I tested with version "144.0b7 (64-bit)" and I still have the same problem.
- What kind of request sets the cookie?
To begin, calling the application's login page generates the cookie via an "html" request that contains a "set-cookie" response header, for example:
Set-Cookie: XSRF-XXX=f27cef1f-5872-4ef5-9b34-25e835def30a; Path=/; Secure; SameSite=None
Then, when calling the login/password verification URL in a POST request, the response to this call again generates a "set-cookie" to update it, this time with two headers:
Set-Cookie: XSRF-XXX=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:10 GMT; Path=/; Secure; SameSite=None
Set-Cookie: XSRF-XXX=262c6f74-da5c-46ff-9220-2db47a6fb8d9; Path=/; Secure; SameSite=None
where XSRF-XXX is the cookie whose value is being updated and for which "document.cookie" returns the old value, that is to say in the example: "f27cef1f-5872-4ef5-9b34-25e835def30a"
-
What are the cookie attributes you are using for the CSRF?
The cookie value is used, no special attributes are used. -
This is an internal business web application, not a website.
The cookie management mechanism containing the CSRF token is handled by the backend via the Spring security framework.
For your information, the issue does not occur in Chrome version "140.0.7339.208" or in Firefox version 140.3.1esr.
Thank's
Seems that the fix only made it into 144.0b8.
Can you update your beta copy of firefox and try again?
Some other questions if you still have the issue:
- Is the first "html" request a top-level navigation?
- How are you triggering the POST?
- Is the domain for the html the same as the POST?
- It might also helpful to show us what devtools > storage > cookies is showing for the domains listed there.
Thanks
| Reporter | ||
Comment 5•1 year ago
|
||
Hi,
Yes, version 144.0b8 does fix the problem, thank you !
Could you provide me with an incident number so I can reference it in my response to my customers?
Thank you.
Thanks!
The issue was handled in Bug 1989488
Description
•