fix(providers): refuse keychain restore across provider ownership - #3845
fix(providers): refuse keychain restore across provider ownership#3845luvs01 wants to merge 1 commit into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe restore flow now validates provider ownership of keychain references before credential access. Tests cover rejection of foreign references, preservation of secrets and configuration, and successful restoration of owned active and pool accounts. ChangesProvider keychain restoration
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Provider keychain restoration now blocks cross-provider credential references without disrupting valid owned accounts. The covered behavior preserves configuration and secrets for rejected references, with no remaining concrete merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request is already Ready for Review. |
리뷰 · 우선순위 75 / 80이 PR은 OS 키체인에 넣어 둔 프로바이더 API 키를 다시 설정으로 되돌리는 복원이 하는 일은 위험합니다. 참조를 따라 키체인에서 비밀을 읽고, 그 값을 해당 프로바이더 설정의 평문 이 변경은 테스트도 결함을 직접 잠급니다. 라인 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
fix(providers): refuse keychain restore across provider ownership (carry #3845)
|
Landed on |
Summary
restoreProviderKeyFromKeychainwhen a provider's config references a keychain account it does not ownstoreProviderKeyInKeychainwrites exactly two account shapes for a provider:<name>for the active key and<name>/<pool id>for pool entries.restoreProviderKeyFromKeychainnever checked that the references it follows match the provider it was asked to restore. It reads each referenced secret, writes it back into that provider's config as plaintext, and then deletes the keychain item.So a config where provider
acarrieskeychain:bturns one restore ofainto two problems:b's secret is disclosed as plaintext undera, andb's credential is deleted from the OS keychain whileb's own config still points at the now-empty account. The refusal happens before anything is read or removed, so config and keychain are both left untouched.This is deliberately scoped to the ownership check in one file. Threading a provider name through
resolveProviderApiKeytouches ~28 request-time call sites and belongs in a separate change; this one stands alone and needs no caller updates.Verification
Run on
agent/keychain-reference-owner-scope-20260907, one commit ahead ofdevbf85e675484a2391b94b2135bbebe739813a9621with nothing behind.bun test ./tests/providers/provider-key-store.test.ts— 8 pass, 0 failbun run typecheck— passedbun run privacy:scan— passedgit diff --check— passedThe new regression was confirmed to catch the defect: with
src/providers/key-store.tsreverted todev, the same file reports 7 pass / 1 fail, and passes with the fix in place. A second test asserts the ordinary own-account restore still round-trips.No GUI change, so no screenshot applies.
Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit