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

v2.5.0 chunked cookie values exceed 4096 bytes #269

Closed
nfadili opened this issue Aug 4, 2021 · 1 comment · Fixed by #275
Closed

v2.5.0 chunked cookie values exceed 4096 bytes #269

nfadili opened this issue Aug 4, 2021 · 1 comment · Fixed by #275
Labels
bug Something isn't working

Comments

@nfadili
Copy link

nfadili commented Aug 4, 2021

Describe the problem

Long cookie values are not being chunked to a size below 4096 bytes starting at version 2.5.0. I have put together a POC with an existing Auth0 tenant and application and I am noticing this behavior after upgrading the lib to v2.5.0 from 2.4.0. It seems that the chunking algorithm is not correctly ensuring that cookie values are less than 4096 bytes. I haven't had time to look into the source code too much, my initial guess is maybe the algorithm isn't taking into account other cookie value fields such as HttpOnly or SameSite when calculating chunk size? This PR where this was introduced seems to be targeting this scenario but I am not seeing correct behavior #237

What was the expected behavior?

I expected the same behavior as < v2.5.0 where the cookie would be chunked into name.0, name.1 and each cookie value would be guaranteed to be less than the size limit. I am seeing the name.0 cookie value to be 4104 bytes long. This difference of 8 bytes is causing chrome to reject the set-cookie header. This difference of 8 correlates with the Path=/; property... that might be the issue?

Reproduction

I can't provide a sample app at this time, but I imagine any of your example snippets would work. The key is to make sure the token is large enough to require chunking. I think the easiest way to do this is to inject the token with bloated custom claims with an Auth0 rule.

Here is the configuration I am using for the library:
Screen Shot 2021-08-03 at 5 23 53 PM

Here is the response headers showing the error. I have redacted random bits from the token in an abundance of caution :)
Screen Shot 2021-08-03 at 5 20 06 PM

Environment

  • Version 2.5.0
  • Node.js, express, no other frameworks should be interfering as far as I can tell
@adamjmcgrath adamjmcgrath mentioned this issue Aug 23, 2021
4 tasks
@adamjmcgrath
Copy link
Contributor

Thanks for raising this @nfadili!

Will be fixed by #275

@adamjmcgrath adamjmcgrath added the bug Something isn't working label Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants