Commit Graph
1 Commits
Author SHA1 Message Date
Luca BeckerandDaniel García a96912bf21 fix(attachments): enforce quota at v2 metadata reservation (#7450)
* fix(attachments): enforce quota at v2 metadata reservation

POST /ciphers/<id>/attachment/v2 persisted client-declared fileSize without
checking USER_ATTACHMENT_LIMIT or ORG_ATTACHMENT_LIMIT, allowing a writer to
exhaust org/user quota via metadata-only reservations before uploading bytes.

Extract shared quota arithmetic into attachment_quota_remaining and use it
from post_attachment_v2 (size_adjust=0) and save_attachment so both paths
stay consistent. Add unit tests covering limit, size_adjust, and the v2
over-quota rejection case.

* Remove unneeded tests and simplify

---------

Co-authored-by: Daniel García <dani-garcia@users.noreply.github.com>
2026-10-28 21:54:06 +01:00