Skip to content

[M2.3-fix] Rule 6/8 audit follow-ups: join token secrets and audited key creation - #110

Merged
samuelmbabhazi merged 4 commits into
mainfrom
fix/rules-audit-follow-ups
Nov 5, 2026
Merged

samuelmbabhazi merged 4 commits into
mainfrom
fix/rules-audit-follow-ups

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

What changed

Follow-ups from the post-merge audit against the CLAUDE.md architecture rules (6 and 8).

  • Join tokens as Secret values (rule 8). IssuedJoinToken.value, the EnrollNode input and the gateway request mapping now carry the token as Secret. It is exposed only where it is hashed or checked for format.
  • Join token issuance commits with its audit event (rule 6). IssueJoinToken runs the insert and fleet.join_token.issued inside FLEET_TRANSACTION. A failed audit write leaves no usable token behind.
  • Installation key creation is audited (rule 6).
    • The CA and confirmation keys are now created in onApplicationBootstrap instead of onModuleInit, so the audit recorder has already subscribed.
    • Each insert commits with a system fleet.installation_key.created event (kind and public-key fingerprint, no organization, no private material).
    • An instance that loses the creation race uses the stored key and records nothing. It no longer logs "created" either.
    • The SPEC data-model section documents this.
  • Database ping log (rule 8). It no longer logs the raw driver error, which can echo the connection string. It logs only the error code.

How it was tested

  • Unit tests:
    • the CA publishes exactly two creation events on first start and none on restart, and no event contains private key material;
    • an audit failure fails startup and keeps no key.
  • New integration test: join token issuance whose audit fails leaves the join_tokens count unchanged.
  • runtime-role.integration.spec.ts now compares the audit count to its value before the denied rewrites, because startup adds two system rows.
  • The HTTP pipeline spec stubs FLEET_TRANSACTION and the audit store (no database).
  • Local gate (CI is unavailable, billing): nx lint, typecheck, test and build; go vet, go test -race and golangci-lint; generation drift; semgrep; prettier. All pass.
  • Not run locally: integration tests (no Docker in this environment).

Security considerations

Two code paths no longer expose secrets: the join token now stays wrapped in Secret, and database driver errors are no longer logged. Two state changes that were previously unaudited are now audited.

Checklist

  • Tests added
  • No new shell invocation, no new secret exposure path
  • Audit events for new state changes
  • SPEC updated

@samuelmbabhazi
samuelmbabhazi merged commit 5017eb2 into main Nov 5, 2026
2 of 11 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the fix/rules-audit-follow-ups branch November 5, 2026 15:23
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
…111)

## What changed

The PLAN now states what remains after the post-merge audit of PRs #30
to #110.

- **New status section.** It covers:
  - what is done;
- the verification gap: CI has been blocked by billing since #87, so
integration, browser, CodeQL and gosec runs are missing. New task CI-1
reruns them first;
  - the next tasks in dependency order;
  - previously unowned work, now assigned to tasks;
  - the decisions waiting for the maintainer.
- **M1.2 and M1.2b ticked.** Their acceptance is met. The join-token
REST endpoint, node list/revoke and the install command with the CA
fingerprint move to a new task, **M2.7**, which depends on M2.3d and
M2.3g1.
- **New splits:**
  - M1.4a/b/c (action dispatch over `Connect` becomes M1.4a);
- M2.3f1/f2 and M2.3g1/g2. M2.3g1 records that `node_certificates` lacks
`organization_id` and needs an ADR;
  - M2.4a/b (partly done: append-only grants and their test exist);
  - M2.5a/b.
- **Stale M2.3 bullet removed.** Live owner authorization for API tokens
was delivered in M2.3d2.
- **M2.6 marked partly done** by M2.2e. The SSE endpoint is assigned to
it.
- **`ExecStream`, `CollectFacts`, `UpgradeAgent` and retry-safe
renewal** are assigned to M6.1, M1.6, M8.3 and M4.5.
- **SPEC 4.** It now names the `public` schema actually used, instead of
`shipkeep`.
- **SPEC 16.** New open question on confirmation tokens for in-place
`RestoreVolume`/`RestoreDatabase`. This would change the action list, so
the maintainer decides.

## How it was tested

Docs only. Prettier and the local gate pass.

## Security considerations

None in code. The document records a missing confirmation requirement
and an unapproved license (`argparse`, PSF-2.0) as maintainer decisions.
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