RANGER-5690: UnixAuth service lacks rate limiting on authentication a…#1106
Open
vyommani wants to merge 1 commit into
Open
RANGER-5690: UnixAuth service lacks rate limiting on authentication a…#1106vyommani wants to merge 1 commit into
vyommani wants to merge 1 commit into
Conversation
ramackri
requested review from
kumaab,
mneethiraj,
pradeepagrawal8184,
spolavarpau1 and
vperiasamy
July 23, 2026 17:59
rameeshm
self-requested a review
July 23, 2026 19:53
ramackri
self-requested a review
July 24, 2026 03:19
ramackri
approved these changes
Jul 24, 2026
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.
What changes were proposed in this pull request?
Extends PR #1080 per-IP rate limiting with account-level fan-out protection for distributed brute-force attempts against the UnixAuth listener.
This PR adds on top of #1080:
Account fan-out delay —
LoginAttemptTrackertracks distinct source IPs failing against the same username. When distinct-IP count exceeds a threshold (default 3), a progressive delay is applied (200ms × over-threshold, capped at 2000ms). Single-IP retries (legitimate admin typos) are never delayed.Account-aware failure/success recording —
PasswordValidatorpasses(sourceIp, username)to the tracker on all failure paths and clears both on success.New config keys in
ranger-ugsync-default.xml:ranger.usersync.unixauth.account.fanout.enabledtrueranger.usersync.unixauth.account.distinct.ip.threshold3ranger.usersync.unixauth.account.window.ms60000ranger.usersync.unixauth.account.base.delay.ms200ranger.usersync.unixauth.account.max.delay.ms2000Also inherits from #1080: per-IP lockout, generic failure responses, socket timeout, optional TLS client-auth.
How was this patch tested?
Unit tests (automated)
unixauthserviceunixauthclientLoginAttemptTrackerTest(18 tests): per-IP lockout (6 from #1080) + account fan-out (12 new): single-IP never delayed, distinct-IP threshold, linear scaling, cap, success/window reset, disabled mode, concurrency, null-account safety.TestPasswordValidator(9 tests): blocked IP, failure/success recording with account, generic responses.TestUnixAuthenticationService(10 tests): config loading, tracker wiring, socket timeout, validator thread spawn.E2E exercises the real
UnixAuthenticationService.startService()listener with production-default fan-out settings. Does not require Docker, usersync tarball, or nativecredValidator.uexe— mock shell validators substitute.Prerequisites: JDK 8+, Maven, Python 3, checkout of this PR branch.
git fetch origin pull/1106/head:RANGER-5690-1 git checkout RANGER-5690-1 cd unixauthservice mvn package -DskipTests mvn dependency:build-classpath -Dmdep.outputFile=target/test-cp.txtWire protocol (unchanged)
Step 1 — Mock validator scripts
Save as
mock-validator-fail.sh:Save as
mock-validator-ok.sh:Step 2 — Start test listener (plain TCP)
Save as
UnixAuthE2eServer.javainunixauthservice/Compile and start (background):
Step 3 — External TCP client (Python)
Save as
unixauth-e2e-client.py:Run lockout test:
Expected output:
Step 4 — Enumeration masking + success clears counter
Restart server with
mock-validator-ok.sh, then:Step 5 — Single-IP retries never trigger account fan-out delay
Restart with high IP threshold (
maxFailedAttempts=100) so lockout does not interfere:Verified: all 5 attempts complete in ~30–50ms each — no progressive delay from account fan-out.
Step 6 — Account fan-out from distinct source IPs (optional)
Requires loopback aliases (
127.0.0.2–127.0.0.5). On macOS:If loopback aliases are unavailable, account fan-out is covered by
LoginAttemptTrackerTestunit tests.All-in-one runner (optional)
Save as
run-unixauth-e2e.shinunixauthservice/and runchmod +x run-unixauth-e2e.sh && ./run-unixauth-e2e.sh. See testing comment for full script.Reviewer verification (ramackri)
unixauthservice+unixauthclient)