RANGER-5690: UnixAuth service lacks rate limiting on authentication a…#1080
Open
vyommani wants to merge 1 commit into
Open
RANGER-5690: UnixAuth service lacks rate limiting on authentication a…#1080vyommani wants to merge 1 commit into
vyommani wants to merge 1 commit into
Conversation
ramackri
requested review from
dhavalshah9131,
fimugdha,
kishorgollapalliwar,
kumaab and
pradeepagrawal8184
July 16, 2026 08:24
Contributor
|
LGTM |
ramackri
self-requested a review
July 17, 2026 09:11
ramackri
approved these changes
Jul 17, 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?
UnixAuthenticationService accepted unlimited authentication attempts with no rate limiting, delay, or lockout. Any network client that could reach the UnixAuth listener could guess OS passwords at native
crypt()speed, with a username-enumeration side channel from distinct failure responses.This PR adds:
Per-source-IP rate limiting and lockout —
LoginAttemptTrackertracks failed attempts per source IP within a sliding window (default: 5 failures / 60s window / 30s lockout, all configurable viaranger-ugsync-default.xml). Once the threshold is hit, further attempts are rejected before the OS credential validator is invoked. Covers wrong password, validator errors, malformed/empty requests, and connection timeouts.Closed username-enumeration side channel — Network clients now receive a single generic
FAILED: Authentication failed.regardless of whether the password was wrong or the user does not exist. Full detail remains in server-side logs with source IP.Optional TLS client-certificate enforcement — Opt-in
ranger.usersync.unixauth.require.client.auth(defaultfalse) requires clients to present a certificate trusted by the configured truststore.Socket read timeout — Connections that send no data within a configurable window (default 10s) are closed and counted as a failed attempt.
New / modified files
LoginAttemptTracker.javaPasswordValidator.javaUnixAuthenticationService.javaranger-ugsync-default.xmlLoginAttemptTrackerTest.javaTestPasswordValidator.javaConfig keys (defaults)
ranger.usersync.unixauth.max.failed.attempts5ranger.usersync.unixauth.attempt.window.ms60000ranger.usersync.unixauth.lockout.duration.ms30000ranger.usersync.unixauth.socket.timeout.ms10000ranger.usersync.unixauth.require.client.authfalseHow was this patch tested?
Unit tests (automated)
unixauthserviceunixauthclientLoginAttemptTrackerTest(6 tests): threshold below lockout, lockout at threshold, success clears history, window expiry resets count, re-lock after lockout expires, independent per-IP tracking.TestPasswordValidator(9 tests): generic failure when validator returns distinct message, blocked IP returnsFAILED: Too many attempts. Try again later.without invoking validator, failure/success recorded on tracker, null program / exec errors counted as failures.TestUnixAuthenticationService(10 tests): config loading,LoginAttemptTrackerwiring, socket timeout viasetSoTimeout, validator thread spawn on accept.End-to-end testing (manual, reproducible)
E2E exercises the real
UnixAuthenticationService.startService()listener (TCP accept →setSoTimeout→PasswordValidatorthread →LoginAttemptTracker). It does not require the full usersync tarball, Docker stack, or nativecredValidator.uexe— a mock shell validator is used instead.Prerequisites: JDK 8+, Maven, Python 3, checkout of this PR branch.
git fetch origin pull/1080/head:RANGER-5690 git checkout RANGER-5690 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(always fails with a distinct internal message):Save as
mock-validator-ok.sh(returnsOKforgooduser, fails for others):Step 2 — Start test listener (plain TCP)
The harness below starts
UnixAuthenticationService.startService()withssl=false, threshold 3 (faster demo; production default is 5), and the mock validator. Save asUnixAuthE2eServer.javainunixauthservice/:Compile and start (background):
Step 3 — External TCP client (Python)
Save as
unixauth-e2e-client.py:Run lockout test:
Expected output:
Verified: attempts 1–3 call mock validator but client sees generic message only; attempt 4+ locked out before validator runs.
Step 4 — Enumeration masking + success clears counter
Restart server with
mock-validator-ok.sh, then:All-in-one runner (optional)
Save as
run-unixauth-e2e.shinunixauthservice/:chmod +x run-unixauth-e2e.sh && ./run-unixauth-e2e.shWhat was NOT covered by the manual E2E harness
UnixAuthenticationService -enableUnixAuthdaemoncredValidator.uexe/etc/shadowbinary; mock script substitutesranger.usersync.unixauth.require.client.auth=trueRegression scope
LOGIN:prefix,OK:/FAILED:responses)