Skip to content

[M1.2-fix] Gateway TLS, clock skew and renewal durability follow-ups - #103

Merged
samuelmbabhazi merged 3 commits into
mainfrom
fix/m1.2-review-follow-ups
Nov 5, 2026
Merged

samuelmbabhazi merged 3 commits into
mainfrom
fix/m1.2-review-follow-ups

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

Task

Review follow-ups for the M1.2 stack (#31, #33, #35). Stacked on #36. Refs #14

What changed

Gateway TLS (#31)

  • gatewaySecureContext() holds every TLS setting and is used both when the server starts and at the daily certificate refresh. Node's setSecureContext resets any option it is not given. Before this fix, the first refresh silently dropped the gateway from TLS 1.3 to Node's TLS 1.2 default, where client certificates travel unencrypted.
  • A unit test reproduces Node's behaviour and checks that the minimum survives a refresh.

Certificates and enrollment errors (#31, #33)

  • Node and gateway certificates start 5 minutes before issuance (CLOCK_SKEW_ALLOWANCE_MS). The 30-day validity still runs from issuance.
  • Before this fix, an agent whose clock was even one second behind rejected its brand-new certificate. The join token was already burned and the node name stuck in enrolling. During renewal, the same skew bricked the node.
  • An oversized CSR now returns InvalidInputError (gRPC InvalidArgument) instead of ConflictError (AlreadyExists).
  • Two concurrent enrollments racing for the same node name now get node_name_taken instead of a raw P2002 mapped to Internal.

Agent renewal durability (#35)

  • RenewCertificate and the following save run under context.WithoutCancel with a 30 s budget. A SIGTERM during renewal no longer cancels an RPC the server may already have committed.
  • A failed save of the renewed credentials (full disk, I/O error) is retried with bounded backoff instead of halting with the only valid key in memory and the old certificate already revoked.
  • SPEC 3.2 documents all of the above.

How it was tested

  • API: nx run-many -t lint typecheck test -p api passes, with new and updated tests for TLS settings, backdated node and gateway certificates, and the oversized-CSR error kind.
  • Agent: go test -race ./agent/... ./lib/... and golangci-lint pass. New tests: a renewal survives two failed saves and is persisted afterwards; a renewal started after cancellation still completes and is persisted.
  • Integration and browser tests 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

Restores the TLS 1.3-only guarantee of the agent gateway. Backdating by 5 minutes slightly extends the validity window into the past and does not change expiry. No change to the action catalogue.

Checklist

  • Lint, TS tests, Go tests pass locally
  • Regression tests added
  • No new shell invocation and no new secret exposure path
  • Audit events unchanged
  • SPEC updated
  • CI green (blocked by billing)

@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m1.2c4b-agent-daemon branch from 496a893 to b6b7230 Compare November 5, 2026 14:32
@samuelmbabhazi
samuelmbabhazi changed the base branch from feat/m1.2c4b-agent-daemon to main November 5, 2026 14:32
@samuelmbabhazi
samuelmbabhazi force-pushed the fix/m1.2-review-follow-ups branch from 60df90c to fe0cea4 Compare November 5, 2026 14:33
@samuelmbabhazi
samuelmbabhazi merged commit 71b2647 into main Nov 5, 2026
2 of 11 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the fix/m1.2-review-follow-ups branch November 5, 2026 14:33
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