You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
I set multiple cookies
Those cookies are included in the response
Actual outcome
The response written to the socket does not include any cookies set before SH middleware gets them.
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[/+]on Apr 22, 2024
Activity
[-]SecureHeaders middleware erases all cookies in Rack 4 due to \n joining[/-][+]SecureHeaders middleware erases all cookies in Rack 3 due to \n joining[/+]collinsauve commentedon Apr 22, 2024
I've put together a minimum-viable reproduction of the issue:
https://github.com/collinsauve/secure-headers-issue-514
fix(cookies): Remove joining with \n
adfoster-r7 commentedon Jul 30, 2025
I'm also hitting an error for this code path, but now from the thin 2.x upgrade a validaiton error is raised due to the
\n
char being present: