fix(sandbox): gate implicit Dockerfile.odek builds behind operator approval#104
Merged
Conversation
…proval A Dockerfile.odek in the working directory was built automatically with no approval gate, while the analogous sandbox_image/sandbox_env project-config knobs correctly require explicit operator approval. docker build executes the repo-controlled Dockerfile's RUN instructions outside the sandbox threat model (default capabilities, entire working directory readable as build context), so merely running odek inside a malicious repository - including odek serve, which sandboxes by default - granted host-adjacent code execution and workspace exfiltration. Changes: - approveProjectSandbox now also requires approval for an implicit Dockerfile.odek build (sandbox active, no explicit image, file present). The approval is keyed on the Dockerfile content hash, so editing the file invalidates a prior "trust this project" approval. The prompt warns that building runs repo-controlled code with the whole working directory as build context. - setupSandbox enforces the approval non-interactively at build time (env bypass, persisted trust, or in-process session approval), closing the gap where a Dockerfile appears or changes after startup - e.g. a serve-mode sandbox created per WebSocket connection, or a session continuation that re-enables the sandbox. - continueCmd now calls approveProjectSandbox like every other command; previously odek continue applied project sandbox overrides without any approval at all. - docker build runs with --network=none by default so RUN steps cannot fetch attacker payloads or exfiltrate build-context data over the network; ODEK_SANDBOX_BUILD_NETWORK=1 (operator-only) opts back in for legitimate networked builds such as RUN apk add. Regression tests cover the requirement detection, non-TTY fail-closed behavior, env bypass, once-vs-trust semantics, content-change invalidation at both gates, build-time enforcement, and the --network=none default. Docs updated: SANDBOXING.md, SECURITY.md (new section 18b), CONFIG.md, AGENTS.md.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
odek | d581983 | Commit Preview URL Branch Preview URL |
Jul 26 2026, 08:40 AM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the reported finding (verified against current code before fixing):
Changes
1. Approval gate for implicit builds (
cmd/odek/project_sandbox_approval.go)approveProjectSandbox— already invoked at startup byrun,repl,serve,telegram,subagent,schedule, andmcp— now also requires approval when sandbox is active, no explicit image is configured, andDockerfile.odekexists in the working directory. It uses the same mechanism as project sandbox overrides:y= once,t= trust this project) with an explicit warning thatdocker buildexecutes repo-controlledRUNinstructions with the entire working directory readable as build context.~/.odek/project_sandbox_approvals.json(0600), keyed on the project directory and the Dockerfile content hash — editingDockerfile.odekinvalidates a prior trust approval and forces re-review.ODEK_APPROVE_PROJECT_SANDBOX=1bypass for CI; non-TTY runs without approval fail closed.2. Build-time enforcement (
cmd/odek/main.go::setupSandbox)setupSandboxre-verifies approval (env bypass → persisted trust → in-process session approval) immediately beforeResolveImagecan build. This closes the gap the startup prompt alone would leave: aDockerfile.odekintroduced or modified after startup — e.g. written by the agent itself, then triggered via a serve-mode sandbox created per WebSocket connection — cannot be built unapproved. Skipped when an explicit image is configured (the Dockerfile is ignored then).3.
continueCmdgap closed (cmd/odek/main.go)odek continuenever calledapproveProjectSandbox, so project sandbox overrides were applied there with no approval at all (a pre-existing C-1 hole), and it re-enables the sandbox from the session. It now runs the same approval flow.4.
--network=nonefor builds by default (internal/sandbox/sandbox.go)docker buildnow runs with--network=none, soRUNsteps cannot fetch attacker payloads or exfiltrate build-context data over the network.ODEK_SANDBOX_BUILD_NETWORK=1(operator-only — a project cannot set env vars for the odek process) opts back in for legitimate networked builds such asRUN apk add ….Tests
cmd/odek/project_sandbox_approval_test.go: requirement detection (sandbox off / explicit image / missing file → no gate), non-TTY fail-closed with actionable error, env bypass at both gates, once-approval covers the in-process build but does not persist, trust persists and content change invalidates it at both gates, no-Dockerfile no-op.internal/sandbox/sandbox_test.go:--network=nonepresent by default, absent withODEK_SANDBOX_BUILD_NETWORK=1.go test ./... -count=1✅ (28 packages),go vet✅,golangci-lint run internal/sandbox/... cmd/odek/...→ 0 issues ✅Docs updated:
docs/SANDBOXING.md(security callout on theDockerfile.odeksection),docs/SECURITY.md(new §18b),docs/CONFIG.md(env var table + example),AGENTS.md.