Understanding CSRF token implementation. #2835
Unanswered
vkosovskikh
asked this question in
Help
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
Can you please help me understand the double submit csrf token implentation made in next-auth? So, tell me if I am wrong somewhere.
The first step we generate random token, hash it with sha256 and put it to
httpOnly
cookie. Here we use a provided secret or generated secret for hashing. So, is this secret same for every client and request?The second step a client asks server for csrf token value:
{ ..., csrfToken: await getCsrfToken() }
and adds it to req.body. At this point we already have csrfToken in cookies. So, does the server returns the same token based on what is in cookies? If this is correct why can't attacker call getCsrfToken() and get the token?Beta Was this translation helpful? Give feedback.
All reactions