fix(auth): require state in manual-paste callback flow - #424
Conversation
Addresses deep-audit auth finding on manual-paste state binding. The previous check only rejected on mismatch: if (parsed.state && parsed.state !== state) return null; which allowed a bare code with no state to bypass the state-binding check. Now the manual-paste path requires state presence and equality before the callback is accepted. Added regression test for missing state and updated stale auth-list expectation to match current main behavior.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 20 minutes and 46 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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 |
Addresses the deep-audit auth finding on manual-paste state binding.
promptManualCallback()inlib/codex-manager.tspreviously accepted a bare authorization code with nostatebecause it only rejected on mismatch:That bypassed the OAuth state-binding contract in the manual-paste path.
This PR now requires both:
Also adds a regression test for missing state, and refreshes one stale
auth listexpectation intest/codex-manager-cli.test.tsso the focused suite is green on current main.note: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
this pr tightens the oauth state-binding contract in
promptManualCallbackby splitting the old permissive guard into two strict checks: require state presence (!parsed.state) and require state equality (parsed.state !== state). the core fix is correct and closes the bypass where a callback with nostateparam was silently accepted.state=wrong-state(mismatch), which the old code already rejected. the newly-added!parsed.statebranch — the exact path that was exploitable — has no dedicated vitest case.Confidence Score: 4/5
safe to merge once the missing-state regression test is added; the code fix is correct
the guard change on lines 1363-1364 is correct and closes the vulnerability. however, the p1 finding stands: the !parsed.state branch — the exact exploit path — has no vitest coverage, and the pr description overclaims that a missing state test was added when the actual test covers mismatched state (which was already handled correctly by the old code).
test/codex-manager-cli.test.ts — needs a state-absent callback test case
Important Files Changed
Comments Outside Diff (1)
test/codex-manager-cli.test.ts, line 5459-5503 (link)the test at line 5459 passes
state=wrong-state, which the old guard (parsed.state && parsed.state !== state) already rejected correctly — this case was never broken. the reported bug was a bare code with no state param at all, which old code accepted becauseparsed.statewas falsy and the whole condition short-circuited. the new!parsed.statebranch on line 1363 remains completely untested.add a dedicated test with a state-absent callback url, e.g.:
without this case, the 80% branch-coverage threshold may still pass but the specific audit finding that motivated the pr has no regression guard.
Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix(auth): require state in manual-paste..." | Re-trigger Greptile