Skip to content

fix(attestation): check contract access before rewriting it on workflow lookup - #3870

Merged
migmartri merged 1 commit into
mainfrom
fix/sec-612-findorcreate-contract-authz
Dec 2, 2026
Merged

migmartri merged 1 commit into
mainfrom
fix/sec-612-findorcreate-contract-authz

Conversation

@migmartri

@migmartri migmartri commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Attestation init (AttestationService/FindOrCreateWorkflow) can update the contract of an existing workflow when it receives contract bytes. Until now it only checked that the caller could create workflows in the project, so a caller confined to projects (a project-, workflow- or product-scoped API token, or an org member with a project role) could rewrite an organization-level contract shared by other projects.

The endpoint now applies the same contract access check as WorkflowContractService/Update before the update: callers confined to projects can no longer modify organization-level contracts through attestation init, and project-level contracts require update access in their project. Organization-wide tokens and organization administrators are unaffected. The check is shared between both services, and contract policies are validated only after access is granted.

This PR was written with the assistance of Claude Code.

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

View guided diff

…ow lookup

FindOrCreateWorkflow updated the contract of an existing workflow when the
request carried contract bytes, checking only that the caller could create
workflows in the project. A caller confined to projects could therefore
rewrite an organization-level contract shared by other projects.

Run the same contract access check as WorkflowContractService/Update
before the update, and validate the contract policies after it.

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

Chainloop-Trace-Sessions: c399f0fc-26df-4962-a05e-fbc324f9ddef
@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 — 🟢 94% · ✅ 0 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟢 94% 1 ✅ 0 95% AI / 5% Human 4 +272 / -31 15m44s

🟢 94% — 95% AI — ✅ All policies passing

Dec 2, 2026 18:59 UTC · 15m44s · $16.76 · 478 in / 159.6k out · claude-code 2.1.334 (claude-opus-5-5)

View session details ↗

Change Summary

Adds contract-scope authorization before existing-workflow contract updates and policy validation. Moves the existing access guard to the shared service and adds regression coverage for confined and organization-level callers.

AI Session Overall Score

🟢 94% — Focused contract authorization fix with passing regression tests and successful mutation detection.

AI Session Analysis Breakdown

🟢 96% · scope-discipline

No notes.

🟢 95% · alignment

No notes.

🟢 95% · solution-quality

🟢 The handler reuses the shared authorization guard and returns its error before validation or mutation. · High Impact

🟢 94% · verification

🟢 The service package passed after cleanup; the new tests check denied rewrites and permitted contract revisions. · High Impact

🟢 A deliberate global-access mutation made the regression suite fail, and the original guard was restored. · High Impact

🟡 The new suite does not directly exercise existing workflows without contract bytes or new-workflow creation. · Low Severity

🟢 93% · user-trust-signal

No notes.

🟢 90% · context-and-planning

No notes.


File Attribution

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

Status Attribution File Lines
created ai app/controlplane/internal/service/findorcreateworkflow_integration_test.go +225 / -0
modified ai app/controlplane/internal/service/attestation.go +28 / -12
modified ai app/controlplane/internal/service/service.go +19 / -0
modified ai app/controlplane/internal/service/workflowcontract.go +0 / -19

Policies (4)

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

Security Checks — ✅ 6 passing

✅ AI Security Analysis

Reviewed this change against the project's security context (13 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 4 files

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

View guided diff | Re-trigger cubic

@migmartri
migmartri requested a review from a team December 2, 2026 19:29
@migmartri
migmartri merged commit 6507869 into main Dec 2, 2026
16 checks passed
@migmartri
migmartri deleted the fix/sec-612-findorcreate-contract-authz branch December 2, 2026 21:16
@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