fix(api-sharing): M8 audit batch 4 — cross-tenant recipients, member-removal purge, owner revoke, unique active-share index (#214) #219

Merged
amiryahaya merged 1 commit from fix/m8-api-sharing into main 2026-11-17 16:51:07 +01:00
Owner

M8-close audit remediation batch 4 (#214 findings M8-5, M8-15, M8-16, M8-19).

M8-5 (tenant-boundary leak): CreateShare required the recipient to exist but not to share the caller's tenant — a cross-tenant user id was accepted (their lattice rank read as 0 here) and the grant notification delivered the real resource name across tenant boundaries. Now 404 (no existence signal).

M8-15 (removal was reversible): RemoveMember purges the removed user's group memberships — stale rows made them silent group-share recipients (clients encrypted keys for non-members) — and revokes their active grants on the tenant's resources; previously removal was silently reversible on re-invite. The Share-revocation half carries a documented UpwardSeams entry (Org→Sharing) pending task 7.3's grant-revocation public interface; the architecture suite stays green.

M8-16 (unkillable grants): the resource OWNER or a tenant admin can now revoke any active share — previously only the original sharer, so re-shares and departed-sharer grants were permanently unkillable.

M8-19 (revocation not a guarantee): ix_shares_active is now UNIQUE (filtered index + migration) — a double-click produced duplicate active grants and revoking one left its twin alive. Concurrent-create races map to 409 at both create endpoints via DbErrors.IsUniqueConstraintViolation.

Tests: M8SharingFixTests (4) — cross-tenant 404 + same-tenant accepted, owner revokes a member re-share and B's download really dies, duplicate active grant 409, RemoveMember drops memberships + revokes grants. Full suite 1086 green (incl. architecture suite with the new seam).

Part of the M8-close FIX-ALL (umbrella #215, audit #214).

M8-close audit remediation batch 4 (#214 findings M8-5, M8-15, M8-16, M8-19). **M8-5 (tenant-boundary leak)**: CreateShare required the recipient to exist but not to share the caller's tenant — a cross-tenant user id was accepted (their lattice rank read as 0 here) and the grant notification delivered the real resource name across tenant boundaries. Now 404 (no existence signal). **M8-15 (removal was reversible)**: RemoveMember purges the removed user's group memberships — stale rows made them silent group-share recipients (clients encrypted keys for non-members) — and revokes their active grants on the tenant's resources; previously removal was silently reversible on re-invite. The Share-revocation half carries a documented UpwardSeams entry (Org→Sharing) pending task 7.3's grant-revocation public interface; the architecture suite stays green. **M8-16 (unkillable grants)**: the resource OWNER or a tenant admin can now revoke any active share — previously only the original sharer, so re-shares and departed-sharer grants were permanently unkillable. **M8-19 (revocation not a guarantee)**: ix_shares_active is now UNIQUE (filtered index + migration) — a double-click produced duplicate active grants and revoking one left its twin alive. Concurrent-create races map to 409 at both create endpoints via DbErrors.IsUniqueConstraintViolation. Tests: M8SharingFixTests (4) — cross-tenant 404 + same-tenant accepted, owner revokes a member re-share and B's download really dies, duplicate active grant 409, RemoveMember drops memberships + revokes grants. Full suite 1086 green (incl. architecture suite with the new seam). Part of the M8-close FIX-ALL (umbrella #215, audit #214).
fix(api-sharing): M8 audit batch 4 — cross-tenant recipients, member-removal purge, owner revoke, unique active-share index (#214)
Some checks failed
API CI / migrations (pull_request) Failing after 1m26s
API CI / build-and-test (pull_request) Successful in 7m2s
Security CI / security-scan (pull_request) Successful in 3m8s
a8a67ab769
M8-5: CreateShare requires the recipient to share the caller's tenant —
a cross-tenant user id was accepted (their lattice rank read as 0 here)
and the grant notification leaked the real resource name across tenant
boundaries. Now 404 (no existence signal).

M8-15: RemoveMember purges the removed user's group memberships (stale
rows made them silent group-share recipients — clients encrypted keys
for non-members) and revokes their active grants on the tenant's
resources (removal was silently reversible on re-invite).

M8-16: the resource OWNER or a tenant admin can now revoke/expire/
downgrade any active share of the resource — previously only the
original sharer could, so re-shares and departed-sharer grants were
unkillable.

M8-19: ix_shares_active is now UNIQUE (filtered index, migration
included) — duplicate active grants from a double-click meant revoking
one row left its twin granting access. Concurrent-create races map to
409 at both create endpoints via DbErrors.IsUniqueConstraintViolation.

Tests: M8SharingFixTests (4) — cross-tenant 404 + same-tenant accepted,
owner revokes member re-share and the grant really dies, duplicate 409,
RemoveMember purges memberships + revokes grants. Full suite 1088 green.
amiryahaya force-pushed fix/m8-api-sharing from a8a67ab769
Some checks failed
API CI / migrations (pull_request) Failing after 1m26s
API CI / build-and-test (pull_request) Successful in 7m2s
Security CI / security-scan (pull_request) Successful in 3m8s
to 65e38ff47d
All checks were successful
API CI / migrations (pull_request) Successful in 3m4s
API CI / build-and-test (pull_request) Successful in 5m17s
Security CI / security-scan (pull_request) Successful in 3m27s
Desktop CI / lint-and-test (pull_request) Successful in 13m40s
2026-11-17 16:36:20 +01:00
Compare
Sign in to join this conversation.
No description provided.