-
Notifications
You must be signed in to change notification settings - Fork 103
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
Hardening the sticky cookie module #1075
Comments
Let's make the comment from #1074
as part of this issue since it's also about per-vhost logic. It seems we have to introduce some data structure to resolve cookies to vhosts, but it's very unwished to introduce one more data structure like a trie just to match cookies. I propose to encode vhost in the cookie, either in cookie name (e.g. |
The A-B scenario was closed in #1354 since the full chains lookup is performed before sticky session processing. I hadn't found a way to resolve the A-B and similar security problems without full http_chain scans, the flexibility of the chains give too many ways of L7 filtering, and trying to use only cookies for that is efficient. E.g. a client with a valid cookie may request denied URIs that are blocked by http_chains; iptables marks won't be added to skbs if the chains are bypassed and so on. The only requiremt left in the task is about cache-control. |
from #1383 (comment) Also, take care of foreign cookies: if backend sets cookie for a client, never store the Actually it's backend fault if they allow caching |
Attacker may use the same sticky cookie value to access all vhosts protected by Tempesta. The issue greatly affects per-vhost sticky cookie behaviour, so it's highly linked with #685 and probably should be done with it.
Sample scenario:
A.com
;Set-Cookie: __tfw=123
;__tfw=123
set;-Tempesta sends normal reply (from cache or proxied from the backend server.
B.com
, but uses the same sticky cookie__tfw=123
Passing the sticky cookie challenge means that the client - is normal client, not a bot, and we should process all requests from this clients normally. But cookies has a scope, (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Scope_of_cookies for details) and normal browsers won't use the same cookie for different vhosts. Since normal browser won't follow the scenario above, the client should be treated as an attacker and should be blocked.
We must also protect our responses with
Set-Cookie:
header set withCache-Control: private
header in order to deny caching the responses by intermediate caching proxies. Otherwise the cookie value will be saved in the cache of intermediate proxies.At the first sight we must assure that the target vhost for the request conforms the sticky cookie name, and block requests that uses cookies for other vhost. But such solution has a huge performance impact. To allow fast sticky cookie scheduler to work, we must process sticky cookie before
http_chain
(see #1043). Searching among all per-vhost cookies not very cheap, and matching amonghttp_chain
rules is expensive (keep in mind use cases with millions of protected vhosts). The solution that looks nice:http_chain
scans: no such variety of operations and comparisons, optimal algorithm may be used.http_chain
scans are not neededhttp_chain
scans.The text was updated successfully, but these errors were encountered: