feat(security): authz matrix with route auto-discovery + PublicRouteRegistry (task 1.10 slice A, SEC-03/04) #69

Merged
amiryahaya merged 1 commit from feat/1.10-authz-matrix into main 2026-11-06 04:05:24 +01:00
Owner

Part of #25 (task 1.10) — this PR lands the flagship SEC-03/04 harness; rate limits, security headers, ZK canaries, KAT consolidation and the fuzz scaffold follow as the closing PR.

SEC-03 — authz matrix with route auto-discovery (AuthzMatrixTests):

  • Enumerates every endpoint from EndpointDataSource; each route must have an explicit Matrix[] row — a new endpoint without a declared authz contract fails the build (the SEC-03 acceptance). Stale rows (renamed/deleted routes) fail too.
  • Row classes (Public / Account / TenantScoped / Admin) are cross-checked against route metadata — a mislabeled row or a mis-marked route declaration fails.
  • Behavioral sweep of ~113 non-public routes × caller state: anonymous → 401 · suspended → 403 · pending-org → 403 org_approval_pending (tenant-scoped only) · Active-no-workspace → 403 no_workspace (tenant-scoped only) · MFA-pending → 403 except TOTP paths · member passes all central gates · non-SuperAdmin on /api/admin → 403. All 35 public routes verified reachable anonymously. Costs ~2s — the central gates are middleware-enforced, so one sweep covers every route.

SEC-04 — PublicRouteRegistry (src/FailSulit.Api/Authorization/): 33 public routes, each with a justification; api-ci verifies [SsdidPublic] ⇄ registry in both directions plus justification quality. Health/bootstrap/auth/recovery/invitation-lookup/blob routes all registered.

Findings surfaced by the matrix (and what this PR does about them):

  1. GET /health/redis was the only health probe without public metadata (siblings had it) — marked for consistency.
  2. PUT /api/files/{fileId}/blob confirmed public = the UPL-02 unauthenticated-blob-PUT debt from the design audit — registered with an explicit LEGACY justification; enforcement lands with Phase 7 file consolidation (tracker 07-tracker-map row exists). Now impossible to silently change: the matrix row + registry entry pin it.
  3. Legacy wallet duplicates at root (/api/register, /api/authenticate) documented as wallet-freeze keeps.

H-1 dimension note (in the class doc): view-only share / download kill-switch / web-disabled / step-up enforcement arrive with Phases 2/5/7; the matrix covers every dimension with runtime enforcement today (anonymous, suspended, pending-org, no-workspace, MFA-pending, admin, workspace-scoped).

Suite 812/0/39 Release ×3; coverage gate 84.34% ≥ 80 (matrix suite lifted coverage +0.4pt).

**Part of #25** (task 1.10) — this PR lands the flagship SEC-03/04 harness; rate limits, security headers, ZK canaries, KAT consolidation and the fuzz scaffold follow as the closing PR. **SEC-03 — authz matrix with route auto-discovery** (`AuthzMatrixTests`): - Enumerates every endpoint from `EndpointDataSource`; **each route must have an explicit `Matrix[]` row** — a new endpoint without a declared authz contract fails the build (the SEC-03 acceptance). Stale rows (renamed/deleted routes) fail too. - Row classes (Public / Account / TenantScoped / Admin) are cross-checked against route metadata — a mislabeled row or a mis-marked route declaration fails. - **Behavioral sweep** of ~113 non-public routes × caller state: anonymous → 401 · suspended → 403 · pending-org → 403 `org_approval_pending` (tenant-scoped only) · Active-no-workspace → 403 `no_workspace` (tenant-scoped only) · MFA-pending → 403 except TOTP paths · member passes all central gates · non-SuperAdmin on /api/admin → 403. All 35 public routes verified reachable anonymously. Costs ~2s — the central gates are middleware-enforced, so one sweep covers every route. **SEC-04 — `PublicRouteRegistry`** (src/FailSulit.Api/Authorization/): 33 public routes, each with a justification; api-ci verifies `[SsdidPublic]` ⇄ registry **in both directions** plus justification quality. Health/bootstrap/auth/recovery/invitation-lookup/blob routes all registered. **Findings surfaced by the matrix (and what this PR does about them):** 1. `GET /health/redis` was the only health probe without public metadata (siblings had it) — marked for consistency. 2. `PUT /api/files/{fileId}/blob` confirmed **public** = the UPL-02 unauthenticated-blob-PUT debt from the design audit — registered with an explicit LEGACY justification; enforcement lands with Phase 7 file consolidation (tracker 07-tracker-map row exists). Now impossible to silently change: the matrix row + registry entry pin it. 3. Legacy wallet duplicates at root (/api/register, /api/authenticate) documented as wallet-freeze keeps. **H-1 dimension note** (in the class doc): view-only share / download kill-switch / web-disabled / step-up enforcement arrive with Phases 2/5/7; the matrix covers every dimension with runtime enforcement today (anonymous, suspended, pending-org, no-workspace, MFA-pending, admin, workspace-scoped). Suite 812/0/39 Release ×3; coverage gate **84.34%** ≥ 80 (matrix suite lifted coverage +0.4pt).
feat(security): authz matrix with route auto-discovery + PublicRouteRegistry (task 1.10 slice A, SEC-03/04) (#25)
All checks were successful
API CI / build-and-test (pull_request) Successful in 34m41s
4ae1ecbf72
- PublicRouteRegistry: 33 public routes with SEC-04 justifications
- AuthzMatrixTests: endpoint discovery from EndpointDataSource; every route
  requires an explicit matrix row (missing row fails the build); class
  consistency cross-checked against route metadata; [SsdidPublic] <-> registry
  verified both directions
- Behavioral sweeps: ~113 non-public routes x caller state (anonymous 401,
  suspended 403, pending-org/no-workspace gates on tenant-scoped, MFA-pending
  gate, admin 403) + all 35 public routes reachable anonymously
- Findings fixed en route: /health/redis was the only health probe without
  public metadata (consistency); /api/files/{id}/blob PUT confirmed public =
  UPL-02 debt, registered with justification pending Phase 7
Sign in to join this conversation.
No description provided.