-
Notifications
You must be signed in to change notification settings - Fork 72
CSRF gets reset too often causing race condition in browser #71
Comments
Exactly! I suspected this but failed to report it. Thanks for the detail. In the meantime I disable XSRF and check the |
@jkarni This still appears to be a problem ( |
aside from @3noch 's PR, we had thought about addressing it by including an option for CSRF Source. Setting that source to, say, any thoughts on this approach ? |
What is the proper solution to this? We're constantly seeing this bug in our webapp which is soon being deployed into production. It can be triggered by simply navigating too fast. |
@saevarb in the absence of some direction from There are a few other prs on this matter, do any of those help you? |
@mebassett Thanks for the swift response :) I looked around at some of the PRs and mostly decided that I would rather avoid depending on a fork. Instead, I upped the versions of the packages so I could use I'd definitely be interested in helping with/looking at solutions to this. I think your solution sounds very sensible. Is there any reason at all to want the current solution? If both solutions are equally secure, I see no reason to keep one solution around if it tends to lead to race conditions. |
@mebassett if the JWT value is not sufficiently unique, its hash can be guessed by the attacker. The OWASP site has good recommendations.
I think we need to find a suitable reference implementation of the encrypted token pattern, because we should not design our own authentication. |
My fork has the third option implemented (check origin and referer), but I've never had time to write tests for it. If anyone wants to try that I'd be very thankful. |
FWIW, I think the trouble with Double-Submit is that it's designed for traditional page-by-page apps (no AJAX). With AJAX-heavy apps or SPA, you need to use something else. |
@3noch It depends on which Double-Submit. It's probably fine to reset it only on login/logout. I've finally found a reasonably compelling source to confirm this. If you have an XSS vulnerability, a 'single-submit' token (what we have now) doesn't seem to help that much. It complicates the exploit by a few lines, but it does not seem to be a real barrier. Also, this presentation (look for What I think we should strive for is to have most/all the options available and let the developer pick what works well for them and have easy to use but sufficiently secure defaults. |
I recall seeing this option used for SPA. This would be great to have. |
This branch seems to do the trick. |
There is now a
How come, if JWT is signed with a private key and assuming there are no timing attacks. |
@domenkozar Good point! Looks like a misread it as hashing the unsigned JWT contents. Of course including the signature should make it impossible to guess. |
When CSRF is enabled, servant-auth-server will set the cookie on every response. The following will happen in the browser with concurrent requests:
This may be more or less of a problem depending on the JavaScript technology used. The context switching by GHCJS probably makes this even more likely than otherwise, but Angular may also suffer from this race condition.
The text was updated successfully, but these errors were encountered: