mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-05-07 21:15:39 -05:00
[GH-ISSUE #7067] Cipher::to_json() panics on unknown atype instead of returning an error #19377
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mango766 on GitHub (Apr 9, 2026).
Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/7067
Bug Description
Cipher::to_json()insrc/db/models/cipher.rsreturnsResult<Value, Error>, but the match arm for unknownatypevalues callspanic!("Wrong type")rather than returning a properErr.Affected code (around line 395–402):
Why This Matters
Because the whole function signature is
-> Result<Value, crate::Error>, the intent is clearly to propagate failures to callers — but apanic!bypasses that entirely and terminates the Rocket worker thread (or the whole process, depending on the panic hook).A cipher with an unexpected
atypecan end up in the database via:When a user with such a cipher calls
/sync, vaultwarden crashes instead of returning a 500/error response, which also affects all other concurrent users on the same instance.Expected Behavior
Return an
Err(using the existingerr!macro already used elsewhere in the same file) so the error is logged and the request fails gracefully without crashing the server.Suggested Fix
I have a PR ready with this one-line fix.