fix: login refresh when user key is missing - #9
Conversation
|
Warning Review limit reached
More reviews will be available in 3 minutes and 2 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. 📝 WalkthroughWalkthroughThe PR improves vault authentication resilience by distinguishing password-based unlock scenarios from session-refresh flows, and adds an early validation check during sync to detect and report broken Bitwarden sessions before attempting data decryption. ChangesVault Authentication & Session Management
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main.rs (1)
4209-4313:⚠️ Potential issue | 🟠 Major | ⚡ Quick winReuse the normal post-sync reconciliation here.
Because Line 4209 now lets
UnlockPasswordrun while the vault is already unlocked, this branch becomes the session-refresh path. Unlikedo_syncon Lines 4781-4823, it never clearsauthorization_memory, never updateskey_material_fingerprints, and never refreshes the envelope local cache. That means a rotated key can keep its remembered approval, and the next lock/unlock can resurrect stale cached keys from disk. Please route this path through the same reconciliation logic asdo_sync, or extract that block into a shared helper.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main.rs` around lines 4209 - 4313, This branch must perform the same post-sync reconciliation as do_sync: either call or extract do_sync's reconciliation block and invoke it here instead of only calling resolve_pending_sync; specifically ensure you clear authorization_memory, update key_material_fingerprints, and refresh the envelope local cache/state (local_key_cache_data and local_cache_key_state) so rotated keys lose remembered approvals and stale disk keys are not resurrected. Replace or augment the current sequence after loading keys (where resolve_pending_sync(...) is called and before returning) to invoke the shared reconciliation helper (or do_sync) that mutates authorization_memory, key_material_fingerprints, local_key_cache_data, and local_cache_key_state accordingly. Use the existing symbols do_sync (or the new helper name), authorization_memory, key_material_fingerprints, local_key_cache_data, local_cache_key_state, and resolve_pending_sync to locate and integrate the logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/main.rs`:
- Around line 4209-4313: This branch must perform the same post-sync
reconciliation as do_sync: either call or extract do_sync's reconciliation block
and invoke it here instead of only calling resolve_pending_sync; specifically
ensure you clear authorization_memory, update key_material_fingerprints, and
refresh the envelope local cache/state (local_key_cache_data and
local_cache_key_state) so rotated keys lose remembered approvals and stale disk
keys are not resurrected. Replace or augment the current sequence after loading
keys (where resolve_pending_sync(...) is called and before returning) to invoke
the shared reconciliation helper (or do_sync) that mutates authorization_memory,
key_material_fingerprints, local_key_cache_data, and local_cache_key_state
accordingly. Use the existing symbols do_sync (or the new helper name),
authorization_memory, key_material_fingerprints, local_key_cache_data,
local_cache_key_state, and resolve_pending_sync to locate and integrate the
logic.
Summary by CodeRabbit