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

SecureHeaders middleware erases all cookies in Rack 3 due to \n joining #514

Open
collinsauve opened this issue Apr 22, 2024 · 1 comment

Comments

@collinsauve
Copy link

collinsauve commented Apr 22, 2024

Bugs

SecureHeaders is not compatible with this change from Rack 3 as SH uses \n encoded cookies in flag_cookies!:

Response header values can be an Array to handle multiple values (and no longer supports \n encoded headers).

Rack will no longer transform this back into an array for you, and that joined string with \n gets all the way to Puma::Request#str_headers at which point it ignores it due to it being an illegal value.

Expected outcome

Describe what you expected to happen

  1. I set multiple cookies
  2. Those cookies are included in the response

Actual outcome

  1. The response written to the socket does not include any cookies set before SH middleware gets them.
@collinsauve collinsauve changed the title SecureHeaders middleware erases all cookies in Rack 4 due to \n joining SecureHeaders middleware erases all cookies in Rack 3 due to \n joining Apr 22, 2024
@collinsauve
Copy link
Author

I've put together a minimum-viable reproduction of the issue:
https://github.com/collinsauve/secure-headers-issue-514

mscrivo added a commit to affinity/secure_headers that referenced this issue Apr 23, 2024
to fix compatibility with Rack 3.

see github#514
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

No branches or pull requests

1 participant