Repository navigation
[M1.2b1] Authenticate and renew node certificates - #30
Merged
Merged
Conversation
6 tasks done
samuelmbabhazi
force-pushed
the
feat/m1.2b1-certificate-lifecycle
branch
from
November 5, 2026 13:32
7b2009f to
3b136a7
Compare
Collaborator
Author
|
Rebased onto the current main after the M2.2/M2.3 stack merged. Main now has a shared transaction context (
|
samuelmbabhazi
force-pushed
the
feat/m1.2b1-certificate-lifecycle
branch
from
November 5, 2026 14:21
3b136a7 to
2c5e133
Compare
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
## Task [M1.2b2] TLS gateway and unary agent RPCs. Part of #14. Stacked on #30: review and merge #30 first, then retarget this PR to main. Neither PR should be merged automatically. ## What changed Start a dedicated HTTP/2 gRPC listener using Connect-RPC after Nest initializes. Serve `Enroll` and `RenewCertificate` through the existing fleet commands. Use a separate Ed25519 server-auth certificate signed by the installation CA, configure its DNS/IP SAN with `AGENT_GATEWAY_SERVER_NAME`, and refresh the in-memory credentials daily. Client certificates are optional at the TLS handshake solely to support initial enrollment. Every other RPC requires a verified TLS peer, client-auth purpose, SPIFFE identity and a current matching database certificate record. Identity headers are ignored and revoked serials are rejected on every request, including reused connections. Bound message sizes, sanitize errors and close HTTP/2 sessions during shutdown. Make enrollment transactional before exposing it over the network: concurrent uses of one join token produce one node and one certificate, and audit failure rolls back the node, certificate and token consumption. The regression test first reproduced two persisted nodes for one token before this correction. ## Scope and dependencies M1.2b stays open: the CA fingerprint is already returned by `IssueJoinToken`, but the REST endpoint and installation-command UI depend on M2.3/M8.3. `Connect` stream lifecycle and revocation-driven disconnection land with M1.2c. Streaming RPCs currently authenticate and return `Unimplemented`; no leases or actions are claimed to work yet. These boundaries are recorded in PLAN, SPEC, README and THREAT_MODEL. ## How it was tested - Lint, TypeScript typecheck and unit tests. - Real PostgreSQL and HTTP/2 TLS tests: initial enrollment, reused token, missing certificate, spoofed headers, authenticated streaming boundaries, renewal, revocation on a reused connection, unregistered certificate, rogue CA copying a valid identity/serial, server CA trust, hostname checks and message size limits. - Enrollment concurrency and audit-failure rollback tests against PostgreSQL; 19 integration tests in total. - Server certificate tests for DNS/IP SANs, server-only EKU and private-key redaction. - `pnpm gen` succeeds without changes to generated contracts; API build succeeds. - Go tests and protobuf lint; custom Semgrep rules. ## Security considerations The `rejectUnauthorized: false` **server** option permits the certificate-free enrollment handshake. It is not client-side disabling of server verification: the application gate requires `TLSSocket.authorized` on protected RPCs and also checks database registration/revocation. Tests prove a rogue CA cannot bypass the gate even by copying an enrolled node identity and serial. The generic Semgrep `bypass-tls-verification` rule flags this server configuration. Its precise finding is suppressed inline with the server-only rationale above; all other rules remain enabled, and the full CI rule set is rerun. This does not weaken any client-side TLS verification. Connect-RPC dependencies are Apache-2.0. No action catalogue change, host shell execution, plaintext key persistence or new public REST endpoint. ## Checklist - [x] M1.2b2 criteria met and ticked; parent M1.2b remains open for dependent work - [x] Lint, TS tests, Go tests and buf lint pass - [x] Transport and malicious-input tests added - [x] No new shell invocation or secret exposure path - [x] State changes use fleet commands and audit events - [x] SPEC, THREAT_MODEL, PLAN and README updated
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task
[M1.2b1] Certificate authentication and renewal. Part of #14; the gateway follows in M1.2b2 and the agent in M1.2c.
What changed
Authenticate registered certificates against their organization, node, validity and revocation state. Renew certificates using the authenticated identity, with a compare-and-swap that permits only one concurrent renewal. Certificate replacement, revocation and audit recording share a PostgreSQL transaction, including rollback if an event subscriber fails.
Split M1.2b into two reviewable PRs in PLAN.md. No REST endpoint is exposed before RBAC exists.
Why
The TLS gateway needs a server-side identity check and renewal command before accepting agent traffic. A failed renewal must leave the previous certificate usable and must not leave unaudited credentials.
How it was tested
Security considerations
Only a transport-verified certificate identity may reach these commands. CSR names cannot change the identity. The new transaction context is used by certificate and audit repositories; existing enrollment remains unchanged.
As required by the existing one-active-certificate invariant, successful renewal immediately revokes the old serial. If the response is lost after commit, operator-assisted re-enrollment is required. Retry-safe recovery is explicitly recorded as an open question in SPEC.md.
Checklist
Leave this PR open for human review. Do not merge automatically.