feat(router): report decrypted plaintext size in ListObjects responses - #51
Conversation
ListObjects/ListObjectsV2 previously reported the at-rest ciphertext size (plaintext + 28-byte AES-GCM-SIV envelope). Intercept bucket-level list requests, subtract the fixed encryption overhead from every <Size>, and clamp at 0. Bucket sub-resource GETs (acl, versioning, multipart listings, ?versions, …) are still forwarded unchanged. - cryptoutil: export EncryptionOverhead constant + invariant test - router: bucketOnlyPattern + isListObjects, wired into getHandler - handler: extract forwardUpstream; add handleListObjects (buffer, rewrite on 2xx, fix Content-Length) - listsize: byte-preserving <Size> regex rewrite + unit tests - e2e: assert v1 and v2 listings report plaintext size Known limitation: objects not written through the proxy (legacy plaintext, server-side copies, multipart) are reported 28 bytes short / 0 after clamp, since list responses carry no per-object encryption metadata.
|
Merged in #55 as part of the v1.9.0 release. Reviewed it end to end while integrating — the approach holds up: buffering a list page (≤1000 keys) is safe, the sub-resource exclusion list is thorough, and recomputing Three observations for a follow-up, none blocking: 1. Path-style addressing only. 2. Content-encoded responses. If an upstream ever returns a gzip-encoded list body, 3. Mixed buckets. Documented in the changelog already, just restating the operational shape: in a bucket where some objects were not written through the proxy, those are reported 28 bytes short — or 0 once clamped, for anything under 28 bytes. Fine for a bucket written exclusively through the proxy (our Loki bucket), worth a warning in the README for anyone pointing this at an existing bucket. |
ListObjects/ListObjectsV2 previously reported the at-rest ciphertext size (plaintext + 28-byte AES-GCM-SIV envelope). Intercept bucket-level list requests, subtract the fixed encryption overhead from every , and clamp at 0. Bucket sub-resource GETs (acl, versioning, multipart listings, ?versions, …) are still forwarded unchanged.
Known limitation: objects not written through the proxy (legacy plaintext, server-side copies, multipart) are reported 28 bytes short / 0 after clamp, since list responses carry no per-object encryption metadata.