Skip to content

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

Open
migmartri wants to merge 1 commit into
mainfrom
miguel/sec-3114-attestation-state-workflow-scope
Open

migmartri wants to merge 1 commit into
mainfrom
miguel/sec-3114-attestation-state-workflow-scope

Conversation

@migmartri

@migmartri migmartri commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

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

View guided diff

…ation RPCs

A workflow-scoped API token could read, overwrite or reset the remote
attestation state of a run that belongs to another workflow in the same
project, and could get CAS upload credentials for that run.

AttestationStateService (Initialized, Save, Read, Reset) and
AttestationService.GetUploadCreds resolve the workflow from the run ID and
check only project RBAC, so the token's workflow scope was never applied.
Move the workflow scope check of AttestationService into a shared helper
and call it from these handlers. The attestation state service now always
resolves the workflow from the run, so it no longer needs the workflow use
case.

Fixes SEC-3114

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

Chainloop-Trace-Sessions: 0a5f115f-a0cb-4013-b6a2-1635aaeb3aa4
@chainloop-platform

chainloop-platform Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

PR validation — ⚠️ 1 failing

Status Policy Material Messages
⚠️ Failed pr-min-approvals pr-info PR/MR #3872 has 0 approving reviews, 1 required.
✅ Passed pr-description-required pr-info -
✅ Passed pr-user-story-linked pr-info -

View attestation ↗

AI Session Checks — 🟡 88% · ✅ 0 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟡 88% 1 ✅ 0 95% AI / 5% Human 3 +292 / -23 12m39s

🟡 88% — 95% AI — ✅ All policies passing

Dec 2, 2026 19:07 UTC · 12m39s · $11.88 · 336 in / 120.1k out · claude-code 2.1.334 (claude-opus-5-5)

View session details ↗

Change Summary

Enforces workflow confinement on state operations and upload credential requests through a shared guard. Adds regression coverage for scoped tokens and robot accounts, including allowed state operations.

AI Session Overall Score

🟡 88% — The tested security fix is sound; adjacent scope expansion and absent user confirmation merit review.

AI Session Analysis Breakdown

🟢 96% · solution-quality

🟢 The shared guard compares both credential scopes against the requested run workflow and propagates denial. · High Impact

🟢 95% · alignment

No notes.

🟢 93% · context-and-planning

🟢 The initial finding names the vulnerable path, identity mismatch, and four-call regression target. · High Impact

🟢 92% · user-trust-signal

No notes.

🟡 78% · verification

🟢 Scope regressions passed after the fix and again after rebase; the full service package also passed. · High Impact

🟠 The user remains engaged through cleanup but never acknowledges that the fixed behavior works. · Medium Severity

🟡 72% · scope-discipline

🟠 AI added GetUploadCreds authorization during cleanup despite the instruction to skip behavior-changing fixes. · Medium Severity

💡 Separate adjacent security fixes or confirm their scope before adding them during cleanup.


File Attribution

███████████████████░ 95% AI / 5% Human

Status Attribution File Lines
created ai app/controlplane/internal/service/attestationstate_integration_test.go +259 / -0
modified ai app/controlplane/internal/service/attestationstate.go +16 / -20
modified ai app/controlplane/internal/service/attestation.go +17 / -3

Policies (4)

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

Security Checks — ⚠️ 1 failing

⚠️ AI Security Analysis

The per-PR audit did not finish: 1 concern went unreviewed (spend ceiling or time). No introduced risk was found in what it reviewed, but treat this as incomplete, not clean.

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.

No issues found across 4 files

View guided diff | Re-trigger cubic

@migmartri
migmartri requested a review from a team December 2, 2026 19:29
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.

1 participant