Repository navigation
Conversation
An API token can be limited by organization, project, product or workflow, and by policies, but not to specific artifacts. A client that hands a token to an untrusted process that must read one artifact needs that restriction. API tokens get an optional list of allowed artifact digests. A client sets it in-process with the APITokenWithAllowedDigests create option. Create refuses an empty list, a digest that is not a sha256 digest, and a token whose policies allow an artifact upload. When the list is set, CASCredentialsService.Get and CASRedirectService.GetDownloadURL refuse a request with no digest or with a digest outside the list, Get refuses the uploader role, and the CAS credential is always scoped to the requested digest. Each RPC refuses with the error it already uses for an artifact out of reach. The new api_tokens.allowed_digests column is nullable and has no default, so existing tokens keep their behavior. Assisted-by: Claude Code Signed-off-by: Javier Rodriguez <javier@chainloop.dev> Chainloop-Trace-Sessions: 5aac1986-3c81-429d-a6e2-ba72c55819b9
PR validation —
|
| Status | Policy | Material | Messages |
|---|---|---|---|
pr-min-approvals |
pr-info |
|
|
| ✅ Passed | pr-description-required |
pr-info |
- |
pr-user-story-linked |
pr-info |
PR/MR #3844 does not reference a user story or issue in title, description, or branch 'feat(controlplane): restrict an API token to a list of artifact digests'. Expected patterns: ["(?i)[A-Z]+-[0-9]+", "#[0-9]+", "(?i)gh-[0-9]+", "(?i)\\[[A-Z]+-[0-9]+\\]"] |
AI Session Checks — 🟡 85% · ⚠️ 2 failing
| Avg score | Sessions | Failing policies | Attribution | Files | Lines | Total Duration |
|---|---|---|---|---|---|---|
| 🟡 85% | 1 | 100% AI / 0% Human | 15 | +436 / -23 | 315h38m10s |
🟡 85% — 100% AI — ⚠️ 2 policies failing
-
Nov 10, 2026 08:24 UTC · 315h38m10s · $1792.52 · 29.2k in / 15.0M out · claude-code 2.1.321 (claude-opus-5-5)
Change Summary
-
Adds optional artifact digest restrictions to API tokens and persists them through request context. Both CAS download paths reject disallowed digests and force scoped credentials; restricted tokens cannot obtain upload credentials. Adds validation, persistence, middleware, and service regression tests.
AI Session Overall Score
-
🟡 85% — Focused digest restrictions have meaningful tests, but captured execution evidence remains unavailable.
AI Session Analysis Breakdown
-
🟢 96% · scope-discipline
-
No notes.
🟢 94% · context-and-planning
-
🟢 The digest-token breakdown names storage, context propagation, both enforcement paths, compatibility, and negative tests. · High Impact
🟢 94% · solution-quality
-
🟢 Credential issuance forces digest scoping and independently rejects uploads rather than trusting caller flags or policies. · High Impact
🟢 93% · alignment
-
No notes.
🟡 75% · user-trust-signal
-
🟠 The user questioned repeated plan iteration: 'make sure we run the validations, why do we keep iterating on the plans?' · Medium Severity
💡 When review iterations repeat, ask for remaining blockers and completion criteria before another pass.
🟡 65% · verification
-
🟢 Service tests inspect issued credential digests and reject missing, disallowed, and upload requests across both endpoints. · High Impact
🟠 Captured commands and execution records contain no run of this PR's digest restriction tests; user confirmation is also unavailable. · Medium Severity
💡 Capture the digest restriction unit and integration test results before pushing the prerequisite change.
-
File Attribution
████████████████████100% AI / 0% Human
Policies (4, 2 failing)
Status Policy Material Messages ✅ Passed ai-config-ai-agents-allowedai-coding-session-5aac19- ⚠️ Failedai-config-no-dangerous-commandsai-coding-session-5aac19Forbidden bash pattern /curl[^|\n]\|\s(?:bash|sh)\b/ matched command: cd /home/javi/orca/workspaces/platform/ai-assisted-manual-evidence/e2e && export TMPDIR=$HOME/.cache/pfm-7910-build/tmp && (yarn install --immutable 2>&1 | tail... ⚠️ Failedai-config-no-secretsai-coding-session-5aac19- Secret (generic-password) detected in session content [turn=101, source=tool_result, line=4]: license_key: "[CHAINLOOP_TRACE_[CHAINLOOP_TRACE_REDACTED:generic-password]:jwt]"
- Secret (generic-password) detected in session content [turn=12318, source=tool_result, line=2]: |
⚠️ Failed |ai-config-no-secrets| [ai-coding-session-5aac19](https://app.chainloop.dev/u/chainloop/projects/chainloop-platf... - Secret (generic-password) detected in session content [turn=15820, source=tool_result, line=8]: INF commit record saved sha=[CHAINLOOP_TRACE_[CHAINLOOP_TRACE_REDACTED:generic-password]:generic-api-key]
- Secret (generic-password) detected in session content [turn=16428, source=tool_result, line=1]: {"headRefName":"javirln/pfm-7910-reconcile-system-tokens","headRefOid":"[CHAINLOOP_TRACE_[CHAINLOOP_TRACE_REDACTED:generic-password]:generic-api-key]","isDraft":false,"reviewDecision":"CHANGES_REQUEST...
- Secret (generic-password) detected in session content [turn=16584, source=tool_result, line=45]: Reviews (5) · Last reviewed commit: ["docs(apitokens): say that a system produ..."](https://github.com/chainloop-dev/platform/commit/[CHAINLOOP_TRACE_[CHAINLOOP_TRACE_REDACTED:generic-password]:g...
- Secret (generic-password) detected in session content [turn=16902, source=tool_result, line=4]: |
⚠️ Failed |ai-config-no-secrets| [ai-coding-session-5aac19](https://app.chainloop.dev/u/chainloop/projects/chainloop-platf... - Secret (generic-password) detected in session content [turn=16941, source=assistant-text, line=4]: -
ai-config-no-secrets(#7252, #7254) checks the record of this AI coding session, not the code. It flagged lines where the tracer had already replaced the values with[CHAINLOOP_TRACE_REDACTED...</li><li>Secret (generic-password) detected in session content [turn=175, source=tool_result, line=32]: license_key: "[CHAINLOOP_TRACE_[CHAINLOOP_TRACE_REDACTED:generic-password]:jwt]"</li><li>Secret (generic-password) detected in session content [turn=18992, source=tool_result, line=1]: git -C ~/.cache/pfm-7910-build/split/b1 push --force-with-lease=javirln/pfm-7910-reconcile-system-tokens:[CHAINLOOP_TRACE_[CHAINLOOP_TRACE_REDACTED:generic-password]:generic-api-key] origin javirln/pf...</li><li>Secret (generic-password) detected in session content [turn=18996, source=assistant-text, line=12]: git -C ~/.cache/pfm-7910-build/split/b1 push --force-with-lease=javirln/pfm-7910-reconcile-system-tokens:[CHAINLOOP_TRACE_[CHAINLOOP_TRACE_REDACTED:generic-password]:generic-api-key] origin javirln/pf...</li><li>Secret (generic-password) detected in session content [turn=19104, source=assistant-tool_use:Bash, line=1]: cd ~/.cache/pfm-7910-build/split && git -C b1 push --force-with-lease=javirln/pfm-7910-reconcile-system-tokens:[CHAINLOOP_TRACE_[CHAINLOOP_TRACE_REDACTED:generic-password]:generic-api-key] origin javi...</li><li>Secret (generic-password) detected in session content [turn=31966, source=tool_result, line=19]: (More exist: passpage_token"[CHAINLOOP_TRACE_[CHAINLOOP_TRACE_REDACTED:generic-password]:generic-api-key]" with the samescope` to list the next ones.) - Secret (generic-password) detected in session content [turn=482, source=tool_result, line=11]: 65 api_key: "[CHAINLOOP_TRACE_REDACTED:generic-password]"
- Secret (generic-password) detected in session content [turn=482, source=tool_result, line=19]: 73 token: "[CHAINLOOP_TRACE_REDACTED:generic-password]"
- Secret (generic-password) detected in session content [turn=6888, source=tool_result, line=7]: # user: [CHAINLOOP_TRACE_REDACTED:generic-password]
- Secret (generic-password) detected in session content [turn=6888, source=tool_result, line=8]: # password: [CHAINLOOP_TRACE_REDACTED:generic-password]
✅ Passed ai-config-mcp-servers-allowedai-coding-session-5aac19- -
Security Checks — ✅ 6 passing
✅ AI Security Analysis
Reviewed this change against the project's security context (31 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 |
Powered by Chainloop and Chainloop Trace
There was a problem hiding this comment.
No issues found across 21 files
Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack
View guided diff | Re-trigger cubic
| @@ -0,0 +1,2 @@ | |||
| -- Modify "api_tokens" table | |||
| ALTER TABLE "api_tokens" ADD COLUMN "allowed_digests" jsonb NULL; | |||
There was a problem hiding this comment.
why do we need to store this? why don't we create a system token?
@jiparis ptal in case I am missing something
|
We can create system tokens scoped to a digest not general purpose api token. Checking everything |
|
Thanks, you are right: digest-scoped CAS credentials already exist, so the API token does not need to store digests. I am closing this PR in favor of #3848, which lets |
API tokens can carry an optional list of artifact digests. The CAS credentials and download URL endpoints then issue download credentials for those digests only.
An AI assistant (Claude Code) helped write this change.