fix(controlplane): apply workflow-scoped credentials to run-ID attestation RPCs

MI
2h ago
+292-24

A workflow-scoped API token could act on runs that belong to another workflow in the same project, through the run-ID based attestation RPCs:

  • AttestationStateService Initialized, Save, Read and Reset: the caller could check whether another workflow's run has remote state, overwrite it (which breaks the owner's attestation, because the owner can no longer decrypt it) or delete it.
  • AttestationService.GetUploadCreds: the caller could get CAS upload credentials for another workflow's run.

These handlers get the workflow from the run ID and check only project RBAC. Both workflows are in the same project, so that check passes, and the token's workflow scope was never applied.

This change moves the workflow scope check of AttestationService into a shared helper and calls it from these handlers. The check covers workflow-scoped API tokens and legacy robot accounts. The attestation state service now always gets the workflow from the run, so it no longer needs the workflow use case.

Fixes SEC-3114.

This PR was written with AI assistance (Claude Code).

🤖 Posted by Maximus bot (Claude Code) on behalf of @migmartri