Skip to content

fix(sandbox): do not mount a ServiceAccount token in sandbox pods - #678

Merged
xiaods merged 2 commits into
mainfrom
fix/sandbox-pod-automount-token
Nov 16, 2026
Merged

xiaods merged 2 commits into
mainfrom
fix/sandbox-pod-automount-token

Conversation

@xiaods

@xiaods xiaods commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #676. Addresses the low-risk part of F9 from docs/security/sandbox-security-review.md.

Change

SandboxPodSpec now sets AutomountServiceAccountToken: false.

Previously the pod received the default ServiceAccount token. That is an unnecessary Kubernetes credential inside an untrusted, agent-controlled workload:

  • sandboxd is a static Zig binary that never talks to the Kubernetes API.
  • The kubelet TCP readiness/startup probes come from the node, not from a pod ServiceAccount.

Dropping the token removes an escalation primitive (a leaked token usable against the API server) without affecting sandbox behaviour.

Deliberately not changed here

The sandbox image runs as root by design (sandbox/Dockerfile: "Root inside the sandbox is safe — isolation is enforced by the RuntimeClass boundary"), and agents need to install packages. SeccompProfile: RuntimeDefault, AllowPrivilegeEscalation: false and dropping capabilities are likely to break real agent workloads (sudo, mount, package managers) and should be a separate, opt-in decision validated against those workloads.

Tests

New TestSandboxPodSpec_DoesNotMountServiceAccountToken in pkg/sandboxmatrix/grpc/orchestrator_test.go.

Validation

go build ./...
go test ./pkg/sandboxmatrix/... -count=1

All pass.

Remaining follow-ups (separate PRs)

  • F8: require a credential on loopback if the gateway host is shared.
  • F10: tighten sanitizePipPackage and shell-quote each specifier.
  • F11: require an explicit K8E_E2B_SIGNING_SECRET in production.
  • Scope snapshots (SnapshotPut/Get/List) per tenant.
  • Optionally SeccompProfile: RuntimeDefault after workload validation.

SandboxPodSpec only set ReadOnlyRootFilesystem. The pod therefore received the
default ServiceAccount token, an unnecessary Kubernetes credential inside an
untrusted, agent-controlled workload: sandboxd is a static Zig binary that never
talks to the API server, and the kubelet TCP probes come from the node.

Set AutomountServiceAccountToken: false. This is the low-risk part of the pod
hardening; seccomp/capability changes need validation against real agent
workloads and are left for a separate decision.
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

1 060 tests  +1   1 033 ✅ +1   6m 58s ⏱️ -11s
  121 suites ±0      27 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit d504bc6. ± Comparison against base commit a737c24.

@sonarqubecloud

Copy link
Copy Markdown

@xiaods
xiaods merged commit c7f8232 into main Nov 16, 2026
6 of 8 checks passed
@xiaods
xiaods deleted the fix/sandbox-pod-automount-token branch November 16, 2026 05:15
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