]> git.ipfire.org Git - thirdparty/squid.git/commit
Limit the number of allowed X-Forwarded-For hops (#1589)
authorThomas Leroy <32497783+p4zuu@users.noreply.github.com>
Tue, 28 Nov 2023 07:35:46 +0000 (07:35 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Thu, 30 Nov 2023 15:32:47 +0000 (04:32 +1300)
commit567e77f6c37047b62dbb4e5afaf9e81f5bd5ae2b
tree57bd6073e92eeab9d6020513b4bc624b6edfaa79
parent82ed0b0dd1ef823516d008f731515ad379a28f87
Limit the number of allowed X-Forwarded-For hops (#1589)

Squid will ignore all X-Forwarded-For elements listed after the first 64
addresses allowed by the follow_x_forwarded_for directive. A different
limit can be specified by defining a C++ SQUID_X_FORWARDED_FOR_HOP_MAX
macro, but that macro is not a supported Squid configuration interface
and may change or disappear at any time.

Squid will log a cache.log ERROR if the hop limit has been reached.

This change works around problematic ACLChecklist and/or slow ACLs
implementation that results in immediate nonBlockingCheck() callbacks.
Such callbacks have caused many bugs and development complications. In
clientFollowXForwardedForCheck() context, they lead to indirect
recursion that was bound only by the number of allowed XFF entries,
which could reach thousands and exhaust Squid process call stack.

This recursion bug was discovered and detailed by Joshua Rogers at
https://megamansec.github.io/Squid-Security-Audit/xff-stackoverflow.html
where it was filed as "X-Forwarded-For Stack Overflow".
src/ClientRequestContext.h
src/client_side_request.cc