rbw edit corrupts entries that have an individual encryption key
Problem
Running rbw edit on an entry that has its own encryption key (an entry with a
key field, e.g. organization/shared items, or items with an item key that may
have been created by the browser extension) silently corrupts the entry. After
the edit, other clients silently fail to display the entry, and rbw fails with
an invalid MAC error, making all functionality unusable.
Steps to reproduce
- Have an entry with a
key field (individual item key)
rbw edit <entry> and change the password (or notes)
- Observe:
rbw get <entry> fails with
failed to decrypt: failed to decrypt encrypted secret: invalid mac
- other clients no longer display the entry / the password and notes fields
cannot be decrypted
rbw login / rbw sync do not help (the corruption lives server-side)
Root cause
The edit path ignores the entry's individual key in two places:
commands.rs re-encrypts the new password/notes with
crate::actions::encrypt(plain, org_id) — which encrypts with the user's
master key (or org key), not with the entry's item key
- The
PUT /api/ciphers/{id} request built in api.rs (CiphersPutReq)
does not include the cipher's key field, so the server keeps the old
(now stale) item key
Result: the item's name/username remain encrypted with the item key, while the
new password/notes are encrypted with the master key, but the item is still
tagged with the item key. No single key can decrypt all fields -> invalid mac
for password/notes on every client.
For a personal entry this is especially bad: the server keeps the now-orphaned
key field, so recovery requires a direct database edit.
Expected behavior
rbw edit should encrypt the new field values with the entry's item key (when
present) and preserve/send the key field on update, mirroring the web vault
and official clients.
Notes
- Reading keyed entries works fine today (the decrypt path unwraps the item
key); only the write/edit path is affected
- A side effect worth noting: a single undecryptable entry causes
rbw list / rbw get / rbw remove to fail for the whole vault, because
entry decryption errors are propagated instead of skipping the entry
rbw edit corrupts entries that have an individual encryption key
Problem
Running
rbw editon an entry that has its own encryption key (an entry with akeyfield, e.g. organization/shared items, or items with an item key that mayhave been created by the browser extension) silently corrupts the entry. After
the edit, other clients silently fail to display the entry, and rbw fails with
an invalid MAC error, making all functionality unusable.
Steps to reproduce
keyfield (individual item key)rbw edit <entry>and change the password (or notes)rbw get <entry>fails withfailed to decrypt: failed to decrypt encrypted secret: invalid maccannot be decrypted
rbw login/rbw syncdo not help (the corruption lives server-side)Root cause
The edit path ignores the entry's individual key in two places:
commands.rsre-encrypts the new password/notes withcrate::actions::encrypt(plain, org_id)— which encrypts with the user'smaster key (or org key), not with the entry's item key
PUT /api/ciphers/{id}request built inapi.rs(CiphersPutReq)does not include the cipher's
keyfield, so the server keeps the old(now stale) item key
Result: the item's name/username remain encrypted with the item key, while the
new password/notes are encrypted with the master key, but the item is still
tagged with the item key. No single key can decrypt all fields ->
invalid macfor password/notes on every client.
For a personal entry this is especially bad: the server keeps the now-orphaned
keyfield, so recovery requires a direct database edit.Expected behavior
rbw editshould encrypt the new field values with the entry's item key (whenpresent) and preserve/send the
keyfield on update, mirroring the web vaultand official clients.
Notes
key); only the write/edit path is affected
rbw list/rbw get/rbw removeto fail for the whole vault, becauseentry decryption errors are propagated instead of skipping the entry