Skip to content

[M2.3g2] Forced row security on audit events - #119

Merged
samuelmbabhazi merged 4 commits into
mainfrom
feat/m2.3g2-audit-rls
Nov 5, 2026
Merged

samuelmbabhazi merged 4 commits into
mainfrom
feat/m2.3g2-audit-rls

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

What changed

M2.3g2: forced row-level security on audit_events, which completes M2.3g.

  • Migration 20261105140000_audit_row_security:
    • tenant_read (SELECT): only events of the active app.org_id. Account and system events (organization_id null) are never readable by the runtime role.
    • append (INSERT): allowed from every command transaction. Inside a tenant context, only events of that organization or of no organization.
    • No UPDATE or DELETE policy, so both are denied on top of the existing SELECT/INSERT-only grants.
  • PrismaAuditEventStore.append. Now uses createMany, which sends no RETURNING clause. Row security checks a returned row as a read, so a create of an account event would have failed.
  • assertTenantDatabaseRole. It now requires 9 forced-RLS tables.
  • Tests:
    • A shared testing/audit-log.ts reader reads stored events through the administrative login. integrationApp and fleetDatabase register and release it.
    • The 15 specs that read audit rows on the restricted login now use it. This is a mechanical replacement of prisma.auditEvent. with auditLog()..
    • runtime-role.integration.spec.ts now proves that the restricted login reads no account events, that a tenant context reads only its own events, and that it cannot append another tenant's.
  • Docs. SPEC 4 describes the policies. SPEC 16 replaces the RLS question with the remaining one: installation-level audit access, proposed for M2.4a. The PLAN ticks M2.3g2 and M2.3g.

Why

The audit read API (M2.4a) must not be able to leak another tenant's history, even through a repository bug.

How it was tested

  • Unit tests (203) and the local gate pass.
  • Not run locally: the integration tests (no Docker). They run in CI-1.

Security considerations

  • The audit log stays append-only and now also stays tenant-confidential.
  • System events (for example installation key creation) are invisible to the API until an audited installation-administrator read path exists.

@samuelmbabhazi
samuelmbabhazi merged commit ad2700b into main Nov 5, 2026
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.3g2-audit-rls branch November 5, 2026 16:18
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