Skip to content

Revoke Git build tokens when their build no longer needs them #547

Done

Description

@samuelmbabhazi

Part of #215. Audited main: deff5f611308aa538cd3981c3e66ca8dd22cced7. This closes a known SPEC limitation and reconciles it with the ADRs; it is not a newly discovered undocumented behavior.

Problem and conditions

A Git build receives a repository-scoped GitHub installation token, but the control plane has no completion cleanup that revokes it. The token remains valid until GitHub's expiration, potentially for the remainder of its one-hour lifetime after a short build. A token minted before the deployment becomes stale can also be abandoned without being revoked.

ADR 0030 and ADR 0031 promise revocation when the build ends. The SPEC's open question correctly says this is not implemented.

Evidence

A local integration test passed using the real API services, Prisma and an ephemeral PostgreSQL database, with a fake GitHub provider recording mint/revoke calls. Configuration creation produced one mint and one revoke. After build access was minted, simulated agent success recorded, and the deployment advanced to its pull stage, there were two mints but still only one revoke. The proof ran at 258cb8b; the relevant production files were verified unchanged in the audited main.

Impact and limits

This prolongs the usefulness of a build token if another flaw or a compromised build component exposes it. It does not independently expose a token, grant repository write access, or cross organization boundaries. Tokens are restricted to one repository, with contents/metadata read permissions, and the action carrying them is encrypted.

No real GitHub credentials, remote revocation, or BuildKit execution were involved in this proof. The stale-return case is established by code inspection, not the successful-build integration scenario.

Proposed correction and acceptance

Give build credentials an explicit cleanup owner. Revoke once the build no longer needs Git access, including unsuccessful or abandoned enqueueing; make terminal cleanup recoverable after process restarts and temporary provider errors. Reuse the existing encrypted-action mechanism or another deliberately designed protected reference, without logging or persisting plaintext tokens.

  • Success, failure, cancellation and expiry schedule idempotent revocation.
  • Minted-but-unused credentials are revoked on stale state or enqueue failure.
  • Cleanup survives a restart and retries provider failures without corrupting deployment state.
  • Tests distinguish configuration-read cleanup from build-token cleanup and verify repository scope remains narrow.
  • SPEC and ADRs describe the same implemented lifecycle and remaining limitations.

Publication check (2026-11-27): main advanced to 817f6ac3b00fdb0e81331e519abc5668a1560aee through #539. The affected production paths cited above are unchanged; the source links retain the audited revision.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority:P2securitytrack:control-plane

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions