-
Bug
-
Resolution: Fixed
-
Major
-
4.3
-
1
-
Team Hedgehog 2024 Sprint 1.2, Team Hedgehog 2024 Sprint 1.3
SameSite In Firefox
Clear any session cookies and then hit the login page on Firefox. You'll see the following in your console:
Cookie “MoodleSession” does not have a proper “SameSite” attribute value. Soon, cookies without the “SameSite” attribute or with an invalid value will be treated as “Lax”. This means that the cookie will no longer be sent in third-party contexts. If your application depends on this cookie being available in such contexts, please add the “SameSite=None“ attribute to it. To know more about the “SameSite“ attribute, read https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite |
That links to https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite
This will likely prevent Moodle from being able to access session cookies in embedded launches, which of course it needs. See MDL-67175 where this was added for Chrome. We may need to include Firefox in that conditional now.
Update: I can't find docs saying when "Soon" is yet, but you can set the default handling in about:config currently via network.cookie.sameSite.laxByDefault (which for me, on v118, is defaulted to false). See also: https://caniuse.com/mdn-http_headers_set-cookie_samesite_lax_default
SameSite In Chrome
The tool code relies on core's should_use_samesite_none() method doing the right thing. This is fragile. Ideally, the tool code would control this cookie in tool launches, and we'd have confidence that a change to the core method above wouldn't break LTI.
This issue should therefore:
- Ensure SameSite=None; Secure; for MoodleSession cookies used during LTI launches - irrespective of browser, and done in the LTI tool code.
To replicate the problem (a problem which will happen in future when Firefox changes their default policy):
Note: This assumes working public, HTTPS setup between 2 Moodle sites, both on different domains. See testing for more information on setting up the LTI links (I'm not going to go into that level of depth in these replication steps).
- Open Firefox and go to about:config
- Set 'network.cookie.sameSite.laxByDefault' to true (the default at the time of writing this is false). This simulates lax treatment in future, which is what the warning hints at.
- Go to the Platform Moodle site
- Go to a course
- Click to add an activity, and select the Tool Moodle site
- Click "Select content"
Expected: You're taken through the usual login flow before being asked to select resources from the Tool.
Actual: You'll get an error during launch, something like "Invalid nonce".
The above "Invalid nonce" error occurs because that's stored in the SESSION, which needs MoodleSession to be sent. It's not being sent because it's not got the proper SameSite=None; Secure; attributes set. The "State" OIDC param however, has been validated since the LTI cookie DOES have SameSite=None; Secure;
Essentially, the state of affairs prior to patching this, is as follows:
Branch | Firefox | Firefox w flag | Chrome |
---|---|---|---|
4.1 | OK | FAIL | OK |
4.2 | OK | FAIL | OK |
4.3 | OK | FAIL | OK |
main | OK | FAIL | OK |