Skip to content

[M2.3c2a-fix] Make key material append-only and track fleet and audit RLS - #99

Merged
samuelmbabhazi merged 1 commit into
mainfrom
fix/m2.3-tenancy-follow-ups
Nov 5, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
fix/m2.3-tenancy-follow-ups

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

Task

Review follow-up for #79 (M2.3b3) and #81 (M2.3c2a). Refs #22

What changed

  • deploy/postgres/runtime-role.sql: the runtime role now gets only SELECT and INSERT on data_encryption_keys and installation_keys, like audit_events. No code updates or deletes these rows: both stores only use findUnique and create, and SPEC 9 says rotation inserts new rows.
  • runtime-role.integration.spec.ts: UPDATE and DELETE on both key tables must now be rejected for the runtime login.
  • PLAN: new task M2.3g, row-level security for nodes, join_tokens, node_certificates and audit_events, with cross-tenant lookups moved to a separate reviewed role. It must land before any node, join-token or audit read endpoint.
  • SPEC 16: open question describing the gap and what the cross-tenant role must cover.

Why

  • With UPDATE or DELETE, an injection or logic bug in the API could delete or overwrite wrapped data-encryption keys, making every secret of an environment unrecoverable, or replace the CA and confirmation keys.
  • The fleet and audit tables carry organization_id but only repository filters protect them. SPEC 4 requires both layers, and the gap was not tracked anywhere ([M2.3b3] Bind fleet records to existing organizations #79 even marked the database isolation task done).

How it was tested

  • nx run-many -t lint typecheck -p api in a clean worktree: clean.
  • The runtime-role integration test needs PostgreSQL. It could not run locally (no Docker in the sandbox), and GitHub Actions is blocked by the account spending limit. CI must pass before merge.

Security considerations

Least privilege for key material. No change to tenant tables. The RLS gap is documented and scheduled, not fixed here, because it needs a design decision on the cross-tenant role (enrollment by join-token hash happens before any tenant context exists).

Checklist

  • Lint and typecheck pass locally
  • Integration test extended
  • No new shell invocation and no new secret exposure path
  • Audit events: not applicable
  • PLAN and SPEC updated
  • CI green (blocked by billing)

@samuelmbabhazi
samuelmbabhazi force-pushed the fix/m2.3-tenancy-follow-ups branch from 8f84cd7 to 7ae00a8 Compare November 5, 2026 13:57
@samuelmbabhazi
samuelmbabhazi merged commit 16f959c into main Nov 5, 2026
2 of 11 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the fix/m2.3-tenancy-follow-ups branch November 5, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant