feat(sharing): M8-13 receive-side envelope unpack — grant-key cache, real routes, ghost sweep (#223) #228
No reviewers
Labels
No labels
epic
phase-0
phase-1
phase-2
phase-3
phase-4
phase-5
phase-6
phase-7
phase-8
phase-9
priority/P0
priority/P1
priority/P2
type/backend
type/client
type/docs
type/ops
type/security
type/spike
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/failsulit!228
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/m8-13-receive-envelope"
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?
Implements M8-13 (audit #214): the receive side of sharing never consumed the key envelope — recipients could not unwrap anything shared to them. First M4 follow-on to the M8-3 key provisioning (#227).
What was broken (ghost contract)
list_shared_with_me/list_my_shareshit routes that do not exist (/shares/incoming|outgoing— the server serves/received|/created)Sharemodel (item_id/owner_*/status/signature) had no server counterpart — every list deserialization would failPOST /shares/{id}/respond(accept/decline) has no server route;PUT /shares/{id}likewise (real: PATCH/permission+ PATCH/expiry)decrypt_share_folder_key(sharing_service.rs:268-284) was dead — the envelope sat opaqueWhat lands
/received+/createdprojections gainResourceName(batched per-type lookup — recipients need the name for the UI)ShareDto(server projection); on incoming listing, eachencrypted_keyenvelope is unpacked, the grant key decapsulated with the M8-3-provisioned KEM keys, and cached by resource id (newgrant_key_cachetable, AES-GCM under the account master key). Corrupt envelopes skip that share; the listing survivesfolder_keys::resolve_folder_keyconsults the cache FIRST (a recipient can only open the wrap made FOR them);download_fileconsults the cached DEK for received file shares before the owner-wrap pathShares.EncryptedKeyon folder-key rotation, so the cache is keyed on SHA-256(envelope) — revoke→rotate→re-grant re-decapsulates instead of serving a stale key (review I3)drop_stale_cache); undecryptable rows (stale/cross-account) fall through with a warning instead of erroringSharetype → server projection; deadShareStatus/StatusBadgeremovedReview: dual-pass per repo rules — ponytail (cache-guard churn, cross-account fall-through, TestApi dedupe — all fixed) + full correctness pass (I1/I2 were already fixed in-tree; I3 caught the rotation staleness — fixed with the envelope hash; M1 expiry-clearing now always PATCHes; M2 SK strings zeroized; M3/M4 mock/type/test residue cleaned; M5 server pre-query breadth + M6 cache-warming-at-unlock noted as follow-ups).
Tests: 3 new Rust receive-path tests vs in-process HTTP stub (envelope consumed + cached; real
folder_keys::decapsulateround trip with NO network — cache-before-network pinned; file-share DEK cache; corrupt-envelope survival). Gates: cargo 85/85, clippy clean, tsc clean, vitest 1282 green, server coverage 87.82% ≥ 80% (pre-push hook).Part of #222/#223 M4 scope; receive-side unblocked by M8-3 (#227).
18695eef9f3d3b097bfe