feat(api): M8 7.15 slice 2 — share lattice + read-time re-check + group shares (CLS-05/06) #204

Merged
amiryahaya merged 1 commit from feat/m8-715-classification-core-2 into main 2026-11-16 09:04:13 +01:00
Owner

Second enforcement slice of the CLS lattice (#158). Design decision (as proposed and unobjected): group shares are SNAPSHOT semantics — see below.

CLS-05 grant-time lattice

  • CreateShare: document level ≤ recipient clearance; denial → 403 classification_insufficient + share_denied_classification audit
  • New POST /api/shares/group: lattice vs the group FLOOR, then snapshot materialization — the sharer's client encrypts the resource key per member (zero-knowledge forces per-recipient ciphertext); the server resolves CURRENT membership itself and requires the item list to cover exactly it (missing/non-member → 400); one Share row per member, tagged ShareTargetGroupId. Members joining later do not retroactively hold keys for pre-existing shares — stated honestly here, in the endpoint docs, and as the documented trade-off of snapshot semantics (owner can re-share to cover new members; CLS-06 still gates every row by the holder's clearance).

CLS-06 read-time re-check

Share-granted access re-checks the recipient's clearance on EVERY access: GetFolder, ListFiles, DownloadFile (per-request = per-chunk per §12 CLS-T5), GetFolderKey (the decryption oracle), ListFolders (below-clearance items hidden). Owners keep inherent access to their own content (downgrades don't brick owners out of their own vaults; re-classification is the remedy) — documented residual.

Verification

8 new tests: user-share denial+audit, at/below success, floor gate, snapshot materialization + idempotent re-share (0 new rows), coverage validation, late-joiner-has-no-row, downgrade-bites-on-next-access across all share-granted paths with grant rows untouched, owner-inherent access. Full suite 1070/0/40 locally.

Schema: shares.ShareTargetGroupId (nullable FK, SET NULL on group delete) — migration AddShareTargetGroup exercised by the #196 migrations CI leg.

Fix ride-along: test fixture mirrors the CLS-02 joiner default (Internal clearance on classified tenants).

Second enforcement slice of the CLS lattice (#158). **Design decision (as proposed and unobjected): group shares are SNAPSHOT semantics** — see below. ## CLS-05 grant-time lattice - CreateShare: document level ≤ recipient clearance; denial → 403 `classification_insufficient` + `share_denied_classification` audit - **New `POST /api/shares/group`**: lattice vs the group FLOOR, then snapshot materialization — the sharer's client encrypts the resource key per member (zero-knowledge forces per-recipient ciphertext); the server resolves CURRENT membership itself and requires the item list to cover exactly it (missing/non-member → 400); one Share row per member, tagged `ShareTargetGroupId`. **Members joining later do not retroactively hold keys** for pre-existing shares — stated honestly here, in the endpoint docs, and as the documented trade-off of snapshot semantics (owner can re-share to cover new members; CLS-06 still gates every row by the holder's clearance). ## CLS-06 read-time re-check Share-granted access re-checks the recipient's clearance on EVERY access: GetFolder, ListFiles, DownloadFile (per-request = per-chunk per §12 CLS-T5), GetFolderKey (the decryption oracle), ListFolders (below-clearance items hidden). Owners keep inherent access to their own content (downgrades don't brick owners out of their own vaults; re-classification is the remedy) — documented residual. ## Verification 8 new tests: user-share denial+audit, at/below success, floor gate, snapshot materialization + idempotent re-share (0 new rows), coverage validation, late-joiner-has-no-row, **downgrade-bites-on-next-access across all share-granted paths with grant rows untouched**, owner-inherent access. Full suite **1070/0/40** locally. Schema: `shares.ShareTargetGroupId` (nullable FK, SET NULL on group delete) — migration `AddShareTargetGroup` exercised by the #196 migrations CI leg. Fix ride-along: test fixture mirrors the CLS-02 joiner default (Internal clearance on classified tenants).
feat(api): M8 7.15 slice 2 — share lattice + read-time re-check + group shares (CLS-05/06)
All checks were successful
Security CI / security-scan (pull_request) Successful in 2m15s
API CI / migrations (pull_request) Successful in 5m8s
API CI / build-and-test (pull_request) Successful in 10m33s
860bcc3a95
CLS-05 grant-time lattice filter:
- CreateShare: document level ≤ recipient clearance (flag off /
  unclassified → pass); denial → 403 classification_insufficient +
  share_denied_classification audit (actor, resource, recipient)
- NEW POST /api/shares/group — snapshot group shares: server validates
  document level ≤ group FLOOR, resolves CURRENT membership server-side,
  requires the client's per-member encrypted keys to cover exactly the
  member set (missing/non-member items → 400), materializes one Share
  row per member tagged ShareTargetGroupId. Zero-knowledge forces
  per-recipient key material, so members joining later do NOT
  retroactively hold keys for pre-existing shares (documented; CLS-06
  governs every row at access time). Idempotent vs active duplicate
  shares; per-member notifications.

CLS-06 read-time re-check (share-granted paths; owners keep inherent
access to their own content):
- GetFolder, ListFiles, DownloadFile (per-request = per-chunk, §12
  CLS-T5), GetFolderKey (the decryption oracle), ListFolders (items
  hidden below the recipient's clearance)
- Clearance changes bite on the NEXT access; grant rows untouched
  (pinned by test)

Schema: Share.ShareTargetGroupId (nullable FK groups, SET NULL on group
delete; indexed). Migration AddShareTargetGroup.

Fix ride-along: TestFixture.CreateUserInTenantAsync mirrors the
production CLS-02 joiner default (Internal clearance on classified
tenants).

Tests: ShareLatticeTests (8) — user-share denial + audit, at/below
success, floor gate, snapshot materialization + idempotent re-share,
coverage validation (missing/non-member 400s), late-joiner snapshot,
downgrade-bites-on-next-access across all share-granted paths with
grant rows untouched, owner-inherent-access. Suite 1070/0/40.
AuthzMatrix row for /api/shares/group (Coverage test).
Sign in to join this conversation.
No description provided.