Commit Graph
1 Commits
Author SHA1 Message Date
Dan MolikandVoucher Security 2c9b7c06a9 Return an error instead of panicking on invalid attachment/cipher input (#7989)
Several handlers pass request-controlled values to the database and
.expect() the result, so a value the database rejects (for example a
string containing a NUL byte, which PostgreSQL refuses in text columns)
turns a normal error into a panic:

- POST /api/ciphers/<cipher_id>/attachment/v2 with a NUL byte in the
  attachment key or file name
- POST/PUT /api/ciphers/move with a NUL byte in an ids entry (IDs from a
  JSON body are not validated the way UuidFromParam validates path params)

On the default unwinding builds Rocket catches this and returns 500; on
builds compiled with panic=abort it terminates the process. Any
authenticated user can trigger it, including on their own cipher.

Make the attachment saves propagate the error (the enclosing functions
already return Result), and validate the move handler's cipher IDs up
front, so both return a normal error response instead of panicking.

Co-authored-by: Voucher Security <security@vouchersecurity.com>
2026-11-22 23:07:36 +01:00