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

Set-Cookie exceeds CHUNK_BYTE_SIZE=4000 #296

Closed
indiejoseph opened this issue Feb 17, 2021 · 3 comments · Fixed by #301
Closed

Set-Cookie exceeds CHUNK_BYTE_SIZE=4000 #296

indiejoseph opened this issue Feb 17, 2021 · 3 comments · Fixed by #301
Labels
bug Something isn't working

Comments

@indiejoseph
Copy link

indiejoseph commented Feb 17, 2021

Description

We've just upgraded our project to v1.0.0, and it working fine on local environment with env variables:

AUTH0_SESSION_NAME=ec
AUTH0_COOKIE_DOMAIN=localhost
AUTH0_COOKIE_TRANSIENT=false
AUTH0_COOKIE_HTTP_ONLY=true
AUTH0_COOKIE_SECURE=false
AUTH0_COOKIE_SAME_SITE=lax

However, when the project deployed on Vercel with production environment variables, the callback not able to Set-Cookie, there show Invalid cookie on Chrome browser, and I counted the length of Set-Cookie was exceeded CHUNK_BYTE_SIZE=4000 :

ec.0=eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwiaWF0IjoxNjEzNTQ3MzYyLCJ1YXQiOjE2MTM1NDczNjIsImV4cCI6MTYxMzYzMzc2Mn0..LWCs2X0_DaeTtAzr.5iWw2xVITMDVC22DBB5a6d-UifHVDd5f4mJv76_5o29L4kfM8mN7mj4kYoJgqhh0XyKf45Cyiyw6AVBxLNHAQ4FA3VnXEQPppdinYan4eH2u1cxBY_UF6OdsF4EI4GKBieVvuBhA-tVRyBW3TTkM7FojNT-29CwdgD48Ku_yX5NXeN22MGWum4M8KOtya1tYv83GGPD0y4ljWy5KBn29y29Qj1k_YeIQRS5_Mmfh3o3vkPhYMq9UJyxsm1HZzMDz8MawMdcGvrjWVQgaF-wlWfmTkW77h22I2wToAYRYOcVWMcA4Oeqqt0sPKUeF-gqpi2r0S7AA3iLazohwyvZKnx9vCdAbMXVay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QnOicbVxnrPjclTg3_t0zaZcAVf35zhtKUf-vBzdzup4HUUM97qimJDZqaGzdw2BZz9Ef6v6prAuYeMooSO-2C92JYCYDNGKwF9Wq8206jkvHqzNh1kZgfUbcOYML-Qmmh0W_he_hWiMVp9DtAgU_CtIctUNLIH_dmRO371JQLIDyu_U7Pwx3vctN2hcHFrMEFbQ3Sro5VcqmWVsNrgnWWOa6l3Irs5Lf32BjborcVextb8KHruBcQ755EQPUiIubKuUAbB1uAW-oyx; Domain=.yourevercare.com; Path=/; Expires=Thu, 18 Feb 2021 07:36:02 GMT; HttpOnly; SameSite=Lax

This issue caused by the chunking function, Set-Cookie including session chunk and cookie attributes, but the chunking logic was only take account to the session value length.

Reproduction

Just like the example with the env variables below:

AUTH0_SESSION_NAME=ec
AUTH0_COOKIE_DOMAIN=.abc.com
AUTH0_COOKIE_TRANSIENT=false
AUTH0_COOKIE_HTTP_ONLY=true
AUTH0_COOKIE_SECURE=true
AUTH0_COOKIE_SAME_SITE=strict

Environment

Version: v1.0.0
Chrome: 88

@indiejoseph indiejoseph changed the title Set-Cookie exceed CHUNK_BYTE_SIZE=4000 Set-Cookie exceeds CHUNK_BYTE_SIZE=4000 Feb 17, 2021
@adamjmcgrath adamjmcgrath added the bug Something isn't working label Feb 17, 2021
@adamjmcgrath
Copy link
Contributor

Thanks for raising this @indiejoseph - let me investigate this and get back to you

@adamjmcgrath
Copy link
Contributor

adamjmcgrath commented Feb 18, 2021

Hi @indiejoseph - yep as you point out, the reproduction example creates the following cookie:

'ec.0=[... a 4kb string ...]; Domain=.abc.com; Path=/; Expires=Thu, 18 Feb 2021 07:36:02 GMT; HttpOnly; Secure; SameSite=Strict;'

Which, minus the value, is 105 ASCII characters (= 105 Bytes). So with the value of 4KB - this becomes 4105 Bytes, which goes over the 4096 Byte limit in Chrome.

I'll raise a PR shortly to reduce the Chunk size (or possibly try and take the cookie property's length into account)

@indiejoseph
Copy link
Author

Yes, i think take the cookie attribute's length into account would be better, coz the path and domain length is arbitrary

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