Skip to content

allow multiple set-cookie headers#435

Merged
rofl0r merged 1 commit intotinyproxy:masterfrom
rofl0r:setcookie_multi
Jan 22, 2025
Merged

allow multiple set-cookie headers#435
rofl0r merged 1 commit intotinyproxy:masterfrom
rofl0r:setcookie_multi

Conversation

@rofl0r
Copy link
Copy Markdown
Contributor

@rofl0r rofl0r commented May 2, 2022

  • replace orderedmap for connection headers with linear list

it turned out that a hashmap isn't the right datastructure, as the
special-case header Set-Cookie not only can, but is even heavily
recommended to be used multiple times.

we now use a dumb list as a key-value store for this purpose, but
restrict it to max 256 entries so the linear search can always be
completed in reasonable time in case of an attack.

closes #403

@Shenmin-Z
Copy link
Copy Markdown

Thanks for the fix, when will this be merged and released?

@rofl0r
Copy link
Copy Markdown
Contributor Author

rofl0r commented Nov 17, 2022

once someone tests this PR properly and provides feedback

@LauKr
Copy link
Copy Markdown

LauKr commented Jun 11, 2024

As we encountered this bug as well (see go-gitea/gitea#31202 for reference), we'd kindly like to ask if there is any progress yet.

We were able to confirm that the bug was fixed at least in our case by building a custom tinyproxy (based on the Debian sources https://salsa.debian.org/debian/tinyproxy/-/tags/debian%2F1.11.1-2) after applying these three (1cd92e5, 2508c1a, 78e4a6d) commits on top.
Using this tinyproxy build we confirmed that all cookies are forwarded and the login was successfully possible.

@Mika56
Copy link
Copy Markdown

Mika56 commented Jun 21, 2024

This fixes it for me too

@DefeatAndVictory
Copy link
Copy Markdown

I try to use 1.11.1-2 version ,but do not work . and i also use the lasted 1.11.2version ,do not work to ,only return one cookie . the website can return two cookie
Set-Cookie: acw_tc=3ccdc14f17218845587662038e5f83d2f44b732a2490187dce438c4e4546aa;path=/;HttpOnly;Max-Age=1800
Set-Cookie: VIP9lLgDcAL2S=60IA_zdO6PNu2tROHTDQZG1q_mlOJmUy95Qw90yRHbSDj7bJwq3truzoU63c58S1Laj8YlX0U.CgOFgrh9ixKjkG; Path=/; expires=Sun, 23 Jul 2034 05:15:58 GMT; HttpOnly
but only return the first

Copy link
Copy Markdown

@JGabrielGruber JGabrielGruber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a C expert, but seems good to me!

@JGabrielGruber
Copy link
Copy Markdown

@obnoxxx or @tstenner can you gives a hand? I love this project, and this feature it's a very welcome one <3

@rofl0r
Copy link
Copy Markdown
Contributor Author

rofl0r commented Jan 4, 2025

@LauKr are you running this patch in production since you posted here ?

@LauKr
Copy link
Copy Markdown

LauKr commented Jan 16, 2025

No, we tested and found no issues, however, as we didn't want to check for patches etc manually, we decided to use another proxy for now, even though it's not as minimal any longer.

@mrluanma
Copy link
Copy Markdown

I've been running my deployments with this patch, and it's working great!

it turned out that a hashmap isn't the right datastructure, as the
special-case header Set-Cookie not only can, but is even heavily
recommended to be used multiple times.

we now use a dumb list as a key-value store for this purpose, but
restrict it to max 256 entries so the linear search can always be
completed in reasonable time in case of an attack.

closes tinyproxy#403
@rofl0r rofl0r merged commit 56404a3 into tinyproxy:master Jan 22, 2025
@rofl0r
Copy link
Copy Markdown
Contributor Author

rofl0r commented Jan 22, 2025

ok, thanks to everyone for testing. let's hope sufficient amounts of people compile tinyproxy from git so if there's any more bugs in it it will be discovered in due time.

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 this pull request may close these issues.

multiple Set-Cookie headers do not work with tinyproxy

7 participants