encrypt with item key when editing keyed entries - #366
Open
NanShanFish wants to merge 1 commit into
Open
Conversation
pschmitt
added a commit
to pschmitt/rbw
that referenced
this pull request
Aug 17, 2026
find_entry, find_entry_multi, find_entries_all, find_deleted_entry(_all), list's structured and table output, search, and the TUI's search-index rebuild all propagated a single entry's decrypt failure into failing the entire scan -- so one corrupt cipher anywhere in the vault could make `rbw list`/`get`/`remove`/`set --bulk`/etc. fail across every other, perfectly fine entry too. Skip the bad entry and log a warning instead, everywhere that's scanning/searching across many entries; single-target lookups (`rbw get <uuid>` on the corrupted entry itself) still fail loudly, which is correct there. Matches the second half of upstream doy#364/doy#366 (fixed in the fork only, no PR sent upstream). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Problem
rbw editcorrupts entries that have an individual encryption key (an entrywith a
keyfield). After editing such an entry, its password/notes can nolonger be decrypted by any client (including rbw), failing with
invalid mac.See #364.
Root cause:
key) via the encrypt action, ignoring the entry's item key
CiphersPutReq(PUT /api/ciphers/{id}) never sends the cipher'skeyfield,so the server keeps the stale item key
The result is a mixed-key cipher: name/username encrypted with the item key,
password/notes encrypted with the master key, tagged with an item key that
matches neither. No client can decrypt the whole item.
Changes
src/protocol.rs: addentry_keytoAction::Encryptsrc/bin/rbw/actions.rs: passentry_keythrough the encrypt actionsrc/bin/rbw-agent/actions.rs: whenentry_keyis provided, unwrap the itemkey (decrypt it with the master/org key) and encrypt with the item key
instead of the master key. Extracted as a testable
encrypt_with_keyhelpersrc/bin/rbw-agent/agent.rs: dispatch the newentry_keyargumentsrc/bin/rbw/commands.rs: the edit flow passes the entry'skeywhenre-encrypting, so keyed entries are edited with their own key
src/api.rs: addkeytoCiphersPutReqand send it inClient::edit, sothe server keeps the correct item key
src/actions.rs: threadkeythroughedit/edit_oncewith the item key (and not with the master key)
Result
Editing an entry with an individual key now encrypts the new field values with
the entry's item key and sends the
keyfield on update, so all clientsdecrypt the item correctly. Entries without a
keyfield behave exactly asbefore.
Testing
cargo test(all targets) passescargo fmt/cargo clippy --all-targetscleanFixes #364