feat(sandboxidentity): verify the identity of Chainloop sandboxes
Context: PFM-7678. Design: Spec PFM-7678: Verified identity for Chainloop sandboxes, merged in chainloop-dev/platform#6875. It replaces D-009 of the commit verification spec (chainloop-dev/platform#6821). The platform side is chainloop-dev/platform#6861, which waits for a release with this change.
Today any CLI run can claim to be a Chainloop sandbox. So the platform cannot give a sandbox data that the attestation can trust. With this change, the platform gives each sandbox a signed identity token, and the CLI and the control plane verify it.
- Identity token (R-001, R-003, D-006, D-013): the new
sandboxidentitypackage defines it. It is a JWT signed with a new key for each sandbox. Thex5cheader holds a short-lived certificate from the control plane CA. The token names the organization, the project, the workflow, the sandbox run and the Chainloop token of the sandbox. It holds the commit verification of the attested commit. It has no expiry of its own: the control plane accepts it only with the Chainloop token that it names, and that token expires. - Only the platform can issue it (R-002, D-004, D-005): it needs the new permission
sandbox_identity:create. A caller with this permission gets a certificate with a mark in its subject. No role holds the permission, and only a system API token can hold it. A CA that cannot write the mark gives no certificate. - The CLI verifies it (R-004, R-005, D-007, D-011): the
CHAINLOOP_SANDBOXrunner reads the token from theCHAINLOOP_SANDBOX_IDENTITYenvironment value. The CLI verifies the token against the trusted root of the control plane, in the same way as theattestation verifycommand. Only then is the runner authenticated, and only then doesgit.headrecord the commit verification. A token that does not verify gives a runner that is not authenticated and has no platform data. The CLI logs the reason. - The control plane enforces it (R-006, D-010, D-012): the CLI sends the token with the attestation init request. The control plane verifies it, accepts it only from the Chainloop token that it names, and records it on the workflow run. When the control plane stores an attestation of the sandbox runner, it rejects two cases. One is an authenticated runner without a verified identity. The other is a commit verification that the identity does not hold.
The attestation format does not change, and the other runners do not change.
Notes on the implementation:
- The CLI does not know the organization ID, so it gives no organization to the expected values. The workflow ID comes from the init response of the control plane. The organization in the leaf certificate must be the organization in the claims. The control plane compares the organization, the project and the workflow. So R-003 holds.
- The init response gets
SandboxIdentityResult, which the spec does not name. The CLI authenticates the runner only when the control plane verified the identity and the verification of the CLI also passes. So the CLI and the control plane cannot disagree about the identity. - When the identity holds a signature algorithm, the control plane also compares it with the
signature.algorithmofgit.head. - The EJBCA CA writes the subject from the certificate request, so D-005 does not hold for it. The control plane fails closed. With EJBCA, it gives no certificate with the mark. With any CA, it rejects an issued certificate that has a mark that nobody requested. So an EJBCA deployment issues no identity, and its sandbox runner stays not authenticated, as today. The spec records this difference when the work ships.
- The control plane logs the arguments of each request. For attestation init, the log replaces the identity token with
[REDACTED].
This replaces the unsigned CHAINLOOP_SANDBOX_COMMIT_VERIFICATION value of the first version of this PR. No released CLI reads that value. CommitVerification keeps its JSON tags and status names, because the token carries the commit verification in that format.
AI disclosure: AI assisted with this change.
Assisted-by: Claude Code