Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a security vulnerability in the BFF GraphQL validatePassword(loginName, password, loginType) query by ensuring it cannot be used as an unauthenticated “password correctness oracle”.
Changes:
- Enforces an authenticated session requirement in
ValidatePasswordService.validatePasswordby validatingx-session-idagainst the localzs_sessiontable and throwingUnauthorizedExceptionotherwise. - Adds a dedicated Jest test suite covering missing session header, unregistered session, authenticated success path, and wrong-password behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| zsphere/bff/src/identity/validate/validate.service.ts | Adds session presence + local session lookup gate before forwarding to ValidatePasswordAction. |
| zsphere/bff/src/identity/validate/validate.service.spec.ts | Introduces unit tests to verify the new authentication/session validation behavior and expected return values. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
QiRaining
force-pushed
the
fix/validate-password-auth
branch
from
August 13, 2026 05:40
da072ed to
e7448a2
Compare
The GraphQL query validatePassword(loginName, password, loginType) acted as an unauthenticated password-verification oracle: anyone could probe whether an account's password matches, without any session, enabling online brute-force against account credentials (verified against a live deployment, where the default admin credential was confirmed through this endpoint). ValidatePasswordService.validatePassword now requires a valid session (x-session-id present and registered in the local zs_session table) and throws UnauthorizedException otherwise. The shared ValidatePasswordAction is untouched; it is still used by zone VM password validation. Unit tests added covering the unauthenticated/authenticated paths.
QiRaining
force-pushed
the
fix/validate-password-auth
branch
from
August 13, 2026 05:48
e7448a2 to
ab411bc
Compare
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.
背景(安全漏洞)
validatePassword(loginName, password, loginType)是未认证的 GraphQL 查询:任何人无需任何会话即可探测“某账号密码是否正确”,构成在线密码爆破预言机。已在真实部署上验证:通过该接口确认了默认 admin 口令并完成登录。修复
ValidatePasswordService.validatePassword增加认证门槛:必须携带有效会话(x-session-id且存在于本地zs_session表),否则抛出UnauthorizedException;ValidatePasswordAction未改动。验证
validate.service.spec.ts:4 个用例全过;oxlint0 武器tsc --noEmit通过。后续建议(不在本 PR 范围)
/password/verify的锁定/限速策略。