Skip to content

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

Merged
migmartri merged 2 commits into
mainfrom
fix/getuploadcreds-workflow-scope
Dec 2, 2026
Merged

migmartri merged 2 commits into
mainfrom
fix/getuploadcreds-workflow-scope

Conversation

@migmartri

@migmartri migmartri commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

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

GetUploadCreds resolved the workflow run directly and only checked
project-level RBAC, so a workflow-scoped API token could get CAS uploader
credentials for runs of other workflows in its project, and a legacy robot
account for runs of any workflow in its organization. Apply the same
workflow-scope check the other attestation handlers use.

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 4ecc43f0-f57e-4f64-a240-ef1697c0a6b0
@chainloop-platform

chainloop-platform Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

PR validation — ✅ 3 passing

Status Policy Material Messages
✅ Passed pr-min-approvals pr-info -
✅ Passed pr-description-required pr-info -
✅ Passed pr-user-story-linked pr-info -

View attestation ↗

AI Session Checks — 🟢 89% · ✅ 0 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟢 89% 1 ✅ 0 98% AI / 2% Human 2 +250 / -7 18m7s

🟢 89% — 98% AI — ✅ All policies passing

Dec 2, 2026 19:09 UTC · 18m7s · $6.43 · 218 in / 74.0k out · claude-code 2.1.334 (claude-opus-5-5)

View session details ↗

Change Summary

Adds workflow identity checks before upload credential authorization, sharing the existing confinement guard. Also confines legacy robot accounts in the adjacent workflow lookup/create handler and extends the binding regression suite.

AI Session Overall Score

🟢 89% — The focused confinement fix has passing regressions, with human confirmation and credential-generation coverage still limited.

AI Session Analysis Breakdown

🟢 95% · solution-quality

🟢 The upload handler applies the shared identity comparison before project authorization, returning failures immediately. · High Impact

🟢 94% · alignment

No notes.

🟢 92% · context-and-planning

No notes.

🟢 92% · scope-discipline

No notes.

🟢 88% · user-trust-signal

No notes.

🟡 78% · verification

🟢 Both requested confinement cases failed before the guard and passed afterward with explicit Forbidden assertions. · High Impact

🟢 The full service package passed after the review fix, followed by a final binding-suite rerun. · High Impact

🟠 The engaged user never confirms the implemented behavior works; the post-fix follow-up is an automated review report. · Medium Severity

🟡 Inline-backend fixtures exercise denial but do not exercise successful signed uploader credential generation. · Low Severity


File Attribution

███████████████████░ 98% AI / 2% Human

Status Attribution File Lines
modified ai app/controlplane/internal/service/attestation_integration_test.go +209 / -4
modified ai app/controlplane/internal/service/attestation.go +41 / -3

Policies (4)

Status Policy Material Messages
✅ Passed ai-config-ai-agents-allowed ai-coding-session-4ecc43 -
✅ Passed ai-config-no-dangerous-commands ai-coding-session-4ecc43 -
✅ Passed ai-config-no-secrets ai-coding-session-4ecc43 -
✅ Passed ai-config-mcp-servers-allowed ai-coding-session-4ecc43 -

Security Checks — ✅ 6 passing

✅ AI Security Analysis

Reviewed this change against the project's security context (35 concerns hunted) — no introduced risk found.

View in Chainloop ↗ · How this works ↗

✅ Secret Scan

Status Policy Messages
✅ Passed secrets-detection -

✅ SAST Scan

Status Policy Messages
✅ Passed owasp-top10-2025 -
✅ Passed sast -
✅ Passed cwe-top25 -
✅ Passed cwe-top26-40-cusp -
Scans not applied (3)
Scan Reason
Vulnerability Scan no manifest/lockfile changed
GitHub Actions Scan no workflow files changed
IaC Scan no IaC files changed

View attestation ↗


Powered by Chainloop and Chainloop Trace

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

A legacy robot account skips project-level RBAC, so FindOrCreateWorkflow let
it update the contract of any workflow in its organization or create new
workflows. Bind it to its own workflow, like the other attestation handlers.

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 4ecc43f0-f57e-4f64-a240-ef1697c0a6b0
@migmartri
migmartri requested a review from a team December 2, 2026 19:29
@jiparis

jiparis commented Dec 2, 2026

Copy link
Copy Markdown
Member

Are legacy robot accounts still supported? it could be a good moment to drop them.

@migmartri
migmartri merged commit 9bf02f6 into main Dec 2, 2026
16 checks passed
@migmartri
migmartri deleted the fix/getuploadcreds-workflow-scope branch December 2, 2026 21:37
@migmartri

Copy link
Copy Markdown
Member Author

Merged by eng-autopilot: approved by jiparis; no change request; CI passed (16 check runs, 3 workflow runs); GitHub merge state clean; no Greptile review.

🤖 Posted by Maximus bot (Claude Code) on behalf of @migmartri, using the eng-autopilot skill

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.

2 participants