You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "unbridled-41 (via GitHub)" <gi...@apache.org> on 2026/09/08 13:23:43 UTC
[PR] fix(auth): verify the password before revealing disabled accounts [rocketmq-dashboard]
unbridled-41 opened a new pull request, #4160:
URL: https://github.com/apache/rocketmq-dashboard/pull/4160
Fixes #4159.
## Problem / Evidence
`AuthService.loginDatabaseUser` checks whether the Studio user is enabled **before** comparing the password (`server/src/main/java/org/apache/rocketmq/studio/auth/AuthService.java`, lines 352-359 on base `0a596661`):
```java
RmqStudioUser user = findUserByUsername(request.getUsername())
.orElseThrow(() -> new BusinessException(401, "Invalid username or password"));
if (!Boolean.TRUE.equals(user.getEnabled())) {
throw new BusinessException(403, "User account is disabled"); // before password check
}
if (!passwordHasher.matches(request.getPassword(), user.getPasswordHash())) {
throw new BusinessException(401, "Invalid username or password");
}
```
Two consequences, both reproduced by new regression tests that fail on the unmodified base:
1. **User enumeration** — `loginShouldNotRevealDisabledAccountsBeforeThePasswordIsVerified`: a disabled user with a *wrong* password gets `403 "User account is disabled"` instead of the generic `401`. Actual red output: `Expecting message to be: "Invalid username or password" but was: "User account is disabled"`.
2. **Brute-force bypass** — `disabledAccountLoginsAreRateLimitedLikeWrongPasswords`: `AuthService.login` records rate-limiter failures only for `401` (lines 138-143), so five wrong-password attempts against a disabled account never reach `LoginRateLimiter.MAX_FAILED_ATTEMPTS`; the sixth attempt returns `403` again instead of the expected `429 Too many failed login attempts...`.
## Root cause / Fix
Root cause: the enabled check runs before credential verification, and the rate limiter only counts `401` failures.
Fix: swap the two checks so the password is compared first. A disabled account with a wrong password now gets the generic `401 "Invalid username or password"` (identical to unknown users), which also routes those attempts through the existing `LoginRateLimiter`. After a *correct* password, the existing `403 "User account is disabled"` response is preserved unchanged, so the legitimate UX for disabled accounts is intact.
## Priority & scoring
- Impact 34/40 (unauthenticated credential-hygiene defect on the login path of every database-backed deployment) + breadth 12/20 (only the DB-backed login flow; configured-user login unaffected) + reproducibility 20/20 (deterministic unit-level reproduction) + maintainability value 14/20 (aligns login ordering with the limiter's existing contract) = **PRIORITY 80** ≥ 70.
- Minimal, ordering-only change with full module test coverage → **FIX_CONFIDENCE 95** ≥ 80.
## Tests
- `mvn -o test -Dtest=AuthServiceDatabaseTest -DfailIfNoTests=true` on base: `Tests run: 23, Failures: 2` (the two new regressions above; the 21 pre-existing tests all pass).
- Same command after the fix: `Tests run: 23, Failures: 0, Errors: 0, Skipped: 0`.
- Related module suite after the fix: `AuthServiceDatabaseTest, AuthServiceTest, LoginRateLimiterTest, AuthControllerTest` → `Tests run: 60, Failures: 0, Errors: 0` — BUILD SUCCESS.
- Full backend suite (`mvn -o test`) after the fix: `Tests run: 2134, Failures: 3` — the 3 failures are the pre-existing baseline set (`AuthCorsIntegrationTest` ×2, `AliyunInstanceProviderTest.getGroupProgressShouldMapLagRowsTest` ×1), identical to the pristine base run; **zero new failures**.
## Risk
Low. The change reorders two `if` statements in `loginDatabaseUser`; the only observable differences are intended (wrong-password + disabled → 401 generic message instead of 403, and those attempts now count toward the limiter). Correct-password logins against disabled accounts still return `403 "User account is disabled"`. No API shape changes, no persistence changes. Bootstrapping/`ensureBootstrapUsers` behavior is untouched.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(auth): verify the password before revealing disabled accounts [rocketmq-dashboard]
Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins closed pull request #4160: fix(auth): verify the password before revealing disabled accounts
URL: https://github.com/apache/rocketmq-dashboard/pull/4160
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(auth): verify the password before revealing disabled accounts [rocketmq-dashboard]
Posted by "unbridled-41 (via GitHub)" <gi...@apache.org>.
unbridled-41 commented on PR #4160:
URL: https://github.com/apache/rocketmq-dashboard/pull/4160#issuecomment-5680371932
@lizhimins Thanks for the detailed trade-off notes — reworked as #4339. It adds the disabled + correct password case, keeps the disabled short-circuit ahead of the expensive hash (the stored hash is never used), and answers with a uniform 401 after one dummy PBKDF2 verification — the dummy-hash / uniform-response options from your review. The resulting 403→401 change for disabled accounts that present the correct password is called out explicitly in the PR description; please confirm that behavior change is acceptable, and I'm happy to rework if you'd prefer keeping the 403.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(auth): verify the password before revealing disabled accounts [rocketmq-dashboard]
Posted by "unbridled-41 (via GitHub)" <gi...@apache.org>.
unbridled-41 commented on PR #4160:
URL: https://github.com/apache/rocketmq-dashboard/pull/4160#issuecomment-5585844322
## Verification evidence
- **CI**: the upstream workflow does not start for any branch in this repository at the moment. For this PR's head SHA `733b66698f244e019bd15be097881088d1f36efa`, `gh api /repos/apache/rocketmq-dashboard/actions/runs?head_sha=<sha>` returns exactly one run: `CI (pull_request)` with `conclusion=startup_failure`, and `/commits/<sha>/check-runs` reports `total_count=0` (no check runs, no statuses). This matches recent runs of the base branch itself; nothing here can pass or fail CI.
- **Red** (`mvn -o test -Dtest=AuthServiceDatabaseTest -DfailIfNoTests=true` on base `0a596661` with only the tests added):
- `loginShouldNotRevealDisabledAccountsBeforeThePasswordIsVerified`: `Expecting message to be: "Invalid username or password" but was: "User account is disabled"` (403).
- `disabledAccountLoginsAreRateLimitedLikeWrongPasswords`: expected `429 Too many failed login attempts...` after 5 failures, but the 6th attempt again returned `403 "User account is disabled"` — proving disabled-account attempts never reach the limiter.
- Summary: `Tests run: 23, Failures: 2, Errors: 0` — BUILD FAILURE caused solely by the two new tests; all 21 pre-existing tests in the class pass.
- **Module tests** after the fix: `mvn -o test -Dtest='AuthServiceDatabaseTest,AuthServiceTest,LoginRateLimiterTest,AuthControllerTest'` → `Tests run: 60, Failures: 0, Errors: 0, Skipped: 0` — BUILD SUCCESS.
- **Full suite + baseline comparison** after the fix: `mvn -o test` → `Tests run: 2134, Failures: 3, Errors: 0`. The 3 failures are `AuthCorsIntegrationTest` (×2) and `AliyunInstanceProviderTest.getGroupProgressShouldMapLagRowsTest` (×1) — the documented pre-existing baseline failures, identical to a pristine base run; zero new failures introduced (2134 = 2132 baseline + 2 new regressions).
- **Build**: `mvn -o test` compiles main and test sources before running (BUILD SUCCESS up to the known baseline test failures); this also covers the CI's `backend-build` compile step, which cannot run for the same startup_failure reason.
- **Diff self-check**: `git show 733b6669 --numstat` → `2 files changed, 43 insertions(+), 3 deletions(-)`: `AuthService.java` +4/−2 (the two `if` blocks swapped), `AuthServiceDatabaseTest.java` +40/−0 (two new regressions + no helper changes beyond reusing the existing `user(...)` factory). No unrelated changes; only the two files required for this fix are touched.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(auth): verify the password before revealing disabled accounts [rocketmq-dashboard]
Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins commented on PR #4160:
URL: https://github.com/apache/rocketmq-dashboard/pull/4160#issuecomment-5679163458
Thanks for the careful read of the login path — the observation that a 403 before password verification discloses account state is a fair one. We're going to close this as-is, though, because the trade-offs aren't settled. After the swap, an unauthenticated caller can make the server run a full 210k-iteration PBKDF2 derivation against accounts that can never authenticate, and disabled-account attempts start consuming the per-username lockout budget that previously only counted credential failures — both are policy changes rather than bug fixes. More concretely, neither new test covers "disabled account + correct password", which is the one behaviour that must not regress, so the 403 path is left unpinned. If you'd like to rework this, please add that case and keep the disabled short-circuit ahead of the expensive hash (e.g. verify against a dummy hash, or return a uniform 401 without disclosing state). We'd be glad to review that version.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org