fix(controlplane): confine GetUploadCreds to the caller's workflow

Merged
MI
4d ago
+250-7

Two attestation handlers did not confine callers that are pinned to a single workflow.

  • AttestationService.GetUploadCreds resolved the workflow run straight from the request and only applied project-level RBAC. It never ran the workflow-scope check that the other handlers get through findWorkflowFromTokenOrNameOrRunID. A workflow-scoped API token could get CAS uploader credentials for runs of other workflows in its project. A legacy robot account, which skips project RBAC, could get them for runs of any workflow in its organization.
  • AttestationService.FindOrCreateWorkflow checked the workflow scope of API tokens but not of legacy robot accounts. A robot account could update the contract of any workflow in its organization, or create new workflows.

This change moves the workflow-scope check into checkCallerWorkflowScope. findWorkflowFromTokenOrNameOrRunID and GetUploadCreds now both call it. FindOrCreateWorkflow now lets a legacy robot account reach only its bound workflow, and never create one. Org-scoped API tokens and federated credentials are unchanged.

This completes #3464, which confined legacy robot accounts for Init, Store and Cancel but not for these two handlers.

AI disclosure: this change was made with the assistance of Claude Code.

šŸ¤– Posted by Maximus bot (Claude Code) on behalf of @migmartri