Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to read secret cookie in setup function #67

Open
tochoromero opened this issue Apr 25, 2023 · 0 comments · May be fixed by #68
Open

Failed to read secret cookie in setup function #67

tochoromero opened this issue Apr 25, 2023 · 0 comments · May be fixed by #68

Comments

@tochoromero
Copy link

I hit a weird edge case were the getServerSideProps function get executed twice:
vercel/next.js#13064

The problem is there seems to be a bug in the getSecret function. For some reason it does a toLowerCase on the tokenKey which makes it so it fails to read the existing csrfSecret cookie and it just create a new one, this created a race condition for me when I had a POST call happen to my Next server in between the two setup calls and the XRSF-TOKEN created by the POST call was created with wrong secret. Just removing the toLowerCase will fix the issue.

tochoromero added a commit to tochoromero/next-csrf that referenced this issue Apr 25, 2023
When retrieving the existing CSRF Secret as part of the `setup` function, do not call `toLowerCase` on the token key.
Fixes j0lvera#67
@tochoromero tochoromero linked a pull request Apr 25, 2023 that will close this issue
@tochoromero tochoromero changed the title Failed to red secret cookie in setup function Failed to read secret cookie in setup function Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant