-
Notifications
You must be signed in to change notification settings - Fork 325
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
Hash the value of the sticky cookie #203
Conversation
Signed-off-by: Sylvain Rabot <[email protected]>
Related to traefik/traefik#2299 |
Hi, when do you plan merge this commit? It's very necessary improvement for security. |
@emilevauge could you take a look a this ? |
Signed-off-by: Sylvain Rabot <[email protected]>
Any update here? I am also eager to get it implemented due our recent Penetration testing findings .. |
Hello, some questions about this PR. |
Only for performance reasons, it claims to be more cpu/memory efficient than the standard library.
I guess we could add a map that caches the results of the hashing. Its size should not be greater than the number of backends. |
I've added several flavours of Here the results on my machine:
The benchmark has been written so that it replicates a normal behavior where the list of backends does not mutate much. We can consider that the cache will be appended a few times in order to be filled and then will stay the same until the list of backends changes. In that scenario Let me know what you think. |
Hi, Thank you very much for the benchmarks and sorry for the response time. Considering the small performance gain compared to the complexity introduced and the fact that the |
I reverted the hash cache experiment. |
roundrobin/stickysessions.go
Outdated
switch { | ||
case strings.HasPrefix(needle, "http"): | ||
for _, serverURL := range haystack { | ||
if needle == serverURL.String() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sameURL
use to check only for Path
, Host
and Scheme
equality. If this change is intended could you tell us more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's either creating a net.URL out of the needle
string to compare it with serverURL
with sameURL(...)
or Marshaling serverURL into a string to compare it with needle.
I guess both are pretty similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really close except that with .String()
you will also compare the User
if present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I did not know it was a thing to discard the user info but ok.
Signed-off-by: Sylvain Rabot <[email protected]>
Signed-off-by: Sylvain Rabot <[email protected]>
47528c5
to
da9c284
Compare
Ok so since in addition to hash I have to clone the serverURL and marshal it, I benchmarked it again and it became clear adding cache for computed values improves things a lot:
The cached version is twice faster and use 0 allocs compared to previous version. |
Signed-off-by: Sylvain Rabot <[email protected]>
da9c284
to
c859072
Compare
I'll mention #184 again... |
Hi @sylr, Sorry for the late answer. The cache could be addressed in another PR. |
@sylr Can we please proceed with this? Our Penetration testers are complaining about Internal IP Address Disclosed :-( |
The PR in its current state is the most performant version according to the tests I made so I'm not willing to remove the cache. |
@sylr we love the fact that you are deeply involved in this project, but open source means being able to work together, within a team. If you don't accept any of the feedback from the maintainers, this PR will never move forward and we all think it's too bad. |
I believe I responded to all feedbacks except one so this is just an unfair statement. I'll revert the cash to make this go forward. |
@sylr It's perfectly fair once you take into account the tone of your answer, which is kind of aggressive. |
Or, you know, #184 which allows you to pick how you want to hash it, or if you want to encrypt it.. In use for a few years, billions of requests, numerous external security audits... No cache. Just sayin'. 🕺 |
If the other PR allows for outright encryption of the sticky cookie value (as well as hashing for those who are fine with that) then that would be preferable for us. |
Signed-off-by: Sylvain Rabot <[email protected]>
Having private IPs in client cookies is something that have been flagged by external security audits done for my company's software.