oauth/xai: pin discovery endpoints to trusted auth hosts and reject userinfo - #4094
oauth/xai: pin discovery endpoints to trusted auth hosts and reject userinfo#4094lidge-jun wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@/home/box/developer/review-comments/pr-4094.md |
|
✅ Deterministic PR hygiene checks passed. |
리뷰 · 우선순위 71 / 80이 PR은 xAI OAuth discovery가 돌려준 이 레이어(스택 2층)는 discovery 응답의 초기 엔드포인트만 핀합니다. 신뢰 호스트를 라인 src/oauth/xai.ts · XAI_TRUSTED_AUTH_HOSTS - suffix 매치를 버리고 allowlist로 바꿉니다. apex 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
Summary
validateXaiEndpointinsrc/oauth/xai.ts— the trust check applied to the OIDC discovery response whosetoken_endpointthen receives therefresh_tokenin a POST body (refresh) and the authorization code + PKCE verifier (exchange).auth.x.ai(the live issuer per today's discovery document) andaccounts.x.ai(the second host the reference Grok CLI flow uses) — replacing the previous*.x.aisuffix match that would have accepted any subdomain.https://u:p@auth.x.ai/...) are rejected; previouslynew URL()preserved userinfo and fetch would have turned it into anAuthorization: Basicheader on the token request. The rejection message carries only the parsed lowercase host, never the raw URL, so embedded credentials cannot reach logs.Error("unparseable endpoint URL") instead of leaking a bareTypeError; explicit ports are rejected. The error type staysErrorso the terminal-OAuth classification insrc/oauth/index.tsis unaffected.dev); this PR is layer 2, basecodex/xai-oauth-retry-after. Review only this layer's diff (the tip commit). Retarget todevafter oauth/xai: honor Retry-After and stop retrying aborted token requests #4087 lands.discoverXaiOAuthEndpointswith stubbed discovery payloads (accept live shape +accounts.x.ai; reject http, apexx.ai, unlisted subdomains, userinfo — asserting the message does not echo it — explicit port, malformed input).Verification
bun test,bun run typecheck,bun run privacy:scan. The userinfo test fixture is written as a split string literal ("https://u:p@" + "auth.x.ai/...") specifically so the privacy scan's email pattern does not match it; this was verified by review againstscripts/privacy-scan.ts, not by a local run.ci.ymlPR jobs — Linuxtest, macOSplatform-macos,gates(tsc --noEmit), plus the hygiene/enforce-target gates. Windows andmacos-controlrun only on the cumulative final-headlane=alldispatch before merge.tests/oauth/andtests/server/all useauth.x.aiand keep passing (verified by inspection; CI confirms).Checklist