Skip to content

feat(sandbox-kit): port the kit to Docker Sandboxes v3 and inject the token via the egress proxy - #3854

Open
e00dan wants to merge 3 commits into
chainloop-dev:mainfrom
e00dan:feat/sandbox-kit-v3-proxy-token
Open

e00dan wants to merge 3 commits into
chainloop-dev:mainfrom
e00dan:feat/sandbox-kit-v3-proxy-token

Conversation

@e00dan

@e00dan e00dan commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Refs #3836

Why

How

  • The kit is now a v3 mixin on Docker's built-in claude agent (devel/sandbox-kit/sbx-kit-claude/):
    sbx run --clone claude --kit chainloop/sbx-kit-claude .
  • The token is a host-side sbx secret (sbx secret set chainloop). The sandbox sees a placeholder and the
    egress proxy adds the real value on the control plane and platform hosts, never on the CAS, which uses its own
    token from the control plane.
  • The checks that refused to start an untraced session move from the entrypoint wrapper to an install hook, so
    sbx create fails instead.
  • chainloopToken and chainloopConfig are removed. A chainloop auth login session works through a
    command-backed secret; a self-hosted control plane through sbx secret set-custom and the CHAINLOOP_*_API
    variables.
  • Publishing moves from sbx kit push (v2 only) to docker buildx, signed with sbx kit sign, under the same
    image name. sbxenv.yaml and the README follow.

Why a mixin, not a set or a workload

Mixin (this PR) Set Workload
Command sbx run claude --kit … sbx run chainloop/sbx-kit-claude sbx run chainloop/sbx-kit-claude
Claude login works as in Docker's kit each user approves an anthropic binding same as set
Docker's Claude updates at every sandbox create frozen at each Chainloop publish frozen, plus a manual re-sync
Code Chainloop maintains the kit only the kit only the kit + ~240 lines of Docker's kit
Checks run at create at create at every launch

The mixin keeps Docker in charge of Claude Code and its login, which is what extends: claude did. The cost is
a second name on the command line and checks at create rather than at launch; in a --clone sandbox the repo and
the credential are fixed at create anyway.

v2 kit vs this kit

v2 (sbx ≤ v0.50) v3 mixin (sbx ≥ v0.55)
Command sbx run --clone -e CHAINLOOP_TOKEN ./devel/sandbox-kit/claude sbx run --clone claude --kit ./devel/sandbox-kit/sbx-kit-claude .
Chainloop token in the sandbox's environment host secret store; a placeholder in the sandbox
Token rotation recreate the sandbox sbx secret set chainloop, applies to running sandboxes
Your login session mounted config.toml, copied into the sandbox command-backed secret, read on the host per request
Self-hosted mounted config.toml sbx secret set-custom + CHAINLOOP_*_API
Chainloop traffic bypasses the proxy (NO_PROXY) through the proxy; the CAS is left untouched
Refuses an untraced repo or no credentials at every launch at sbx create
Claude Code v2 template image, no longer updated Docker's built-in kit
Claude login approval an anthropic binding none
Publishing sbx kit push --sign docker buildx + sbx kit sign, same image name

Notes for reviewers

  • Needs sbx v0.55.0 stable, which is not released yet; SBX_VERSION in the publish workflow points at it. Tested on v0.55.0-rc5 (macOS and Linux), including a full publish run in a fork; to be re-checked on v0.55.0 once it ships.
  • Publishing already fails on main: chainloop attestation init stops with "creating workflows during the
    attestation process is disabled for this organization", because the sandbox-kit-package workflow does not
    exist in the chainloop org. This PR keeps that step; creating the workflow (or allowing it) is up to the
    maintainers.
  • The first publish moves chainloop/sbx-kit-claude:latest to the v3 kit; :latest moves only after the
    digest is signed.
  • On Chainloop cloud, a token passed with -e is refused when no chainloop secret is stored: sbx drops it at
    the proxy, although the v3 spec says an unbound optional credential is
    skipped.
  • sbx secret set accepts an empty value, and the install check sees only that a secret is bound, not its value, so an empty chainloop secret passes at create (v2 refused an empty token). As with an expired or wrong token, Claude's session-start banner then reports Chainloop Trace cannot upload this session when you push: your authentication token is invalid…, and git push warns and goes through, or is blocked with --require-trace.
  • Published with Buildx and signed with sbx kit sign, per Docker's
    distribution guide; sbx does not
    verify cosign signatures.
  • The docs guide at docs.chainloop.dev needs the same update; its source is not in this repository.

This change was prepared with AI assistance (Claude Code).

View guided diff

… token via the egress proxy

The kit is a v3 mixin on Docker's built-in claude agent, in
devel/sandbox-kit/sbx-kit-claude/.

- The Chainloop token stays on the host (`sbx secret set chainloop`) and the
  sbx egress proxy injects it; the chainloopToken and chainloopConfig
  arguments are removed.
- The checks that refused to start an untraced agent run at `sbx create`.
- The kit is published with `docker buildx` and signed with `sbx kit sign`,
  still as docker.io/chainloop/sbx-kit-claude.

Requires sbx v0.55.0 or later.

Refs: chainloop-dev#3836

Assisted-by: Claude Code
Signed-off-by: Daniel Kmak <4950658+e00dan@users.noreply.github.com>
@chainloop-platform

chainloop-platform Bot commented Nov 28, 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 — ⚠️ no AI session found

Missing AI Coding Sessions

This organization requires every PR to be backed by a Chainloop Trace AI coding session, and none was found for this one.

Please make sure the AI coding session evidence has been sent by the Chainloop CLI, or add the skip-ai-session label to this PR to bypass this check.

Learn more about Chainloop Trace.

Security Checks — ✅ 8 passing

✅ AI Security Analysis

Nothing this change touches re-opens a recorded security fix.

View in Chainloop ↗ · How this works ↗

✅ Secret Scan

Status Policy Messages
✅ Passed secrets-detection -

✅ GitHub Actions Scan

Status Policy Messages
✅ Passed ci-pipeline-security -

✅ SAST Scan

Status Policy Messages
✅ Passed owasp-top10-2025 -
✅ Passed sast -
✅ Passed cwe-top25 -
✅ Passed cwe-top26-40-cusp -

✅ IaC Scan

Status Policy Messages
✅ Passed iac-misconfiguration -
Scan not applied (1)
Scan Reason
Vulnerability Scan no manifest/lockfile 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.

3 issues found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="devel/sandbox-kit/README.md">

<violation number="1" location="devel/sandbox-kit/README.md:97">
P2: `CHAINLOOP_PLATFORM_API` is ignored by the Chainloop CLI used in this sandbox, so this self-hosted command does not configure its platform endpoint. Remove this option or add corresponding CLI support before documenting it here.</violation>
</file>

<file name="devel/sandbox-kit/sbx-kit-claude/spec.yaml">

<violation number="1" location="devel/sandbox-kit/sbx-kit-claude/spec.yaml:66">
P1: The credential is runtime-only, but the install hook checks its environment before the runtime phase exists, so every normal `sbx secret set chainloop` run is rejected as having no credentials. Declare an install-phase credential as well (with the required install policy) or move this credential check to a runtime lifecycle hook.</violation>

<violation number="2" location="devel/sandbox-kit/sbx-kit-claude/spec.yaml:71">
P2: Older configs targeting `api.cp.chainloop.dev` can reach the allowlisted host but never receive the Chainloop bearer token because the inject list omits that exact domain. Add `api.cp.chainloop.dev` to the credential injection mappings.</violation>
</file>

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

Comment thread devel/sandbox-kit/README.md Resolved
release.yaml runs the script by path; the previous commit dropped its
executable bit by mistake.

Assisted-by: Claude Code
Signed-off-by: Daniel Kmak <4950658+e00dan@users.noreply.github.com>
Without TLS the CLI needs CHAINLOOP_API_INSECURE=true. On Linux the sbx
daemon only picks up a newly trusted CA after a restart; until then the
proxy answers 502.

Signed-off-by: Daniel Kmak <4950658+e00dan@users.noreply.github.com>
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