[fix][broker] Fix potential OOM due to client use sasl authentication - #20713
Merged
Conversation
315157973
requested review from
BewareMyPower,
codelipenghui,
gaoran10 and
poorbarcode
July 4, 2023 12:10
Contributor
Author
|
/pulsarbot run-failure-checks |
JooHyukKim
reviewed
Jul 4, 2023
Codecov Report
@@ Coverage Diff @@
## master #20713 +/- ##
============================================
+ Coverage 72.75% 73.19% +0.44%
- Complexity 32235 32293 +58
============================================
Files 1856 1868 +12
Lines 138999 139313 +314
Branches 15302 15339 +37
============================================
+ Hits 101128 101976 +848
+ Misses 29860 29304 -556
- Partials 8011 8033 +22
Flags with carried forward coverage won't be shown. Click here to find out more.
|
JooHyukKim
approved these changes
Jul 5, 2023
Comment on lines
+116
to
+117
| this.authStates = Caffeine.newBuilder() | ||
| .expireAfterWrite(config.getInflightSaslContextExpiryMs(), TimeUnit.MILLISECONDS).build(); |
Member
There was a problem hiding this comment.
This kind of caching would still be vulnerable to a high frequency of calls, similar to a TCP SYN flood. Should we also put an upper limit on the number of in flight contexts so that old contexts are dropped?
gaoran10
reviewed
Jul 19, 2023
gaoran10
approved these changes
Jul 20, 2023
Technoboy-
approved these changes
Jul 20, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Sasl authentication has two phases. In the first phase, the broker will temporarily cache the authentication info, and clean the cache at the end of the second phase.
When the client crashes after phase 1, or someone deliberately attacks, the auth info will always remain in the broker's memory.
If the client keeps reconnecting like this, the broker will soon OOM.
Modifications
Change ConcurrentHashMap to caffeine cache , and force clean cache after a certain period of time.
Verifying this change
Documentation
doc-not-neededMatching PR in forked repository
315157973#10