Skip to content

docs(security): design a sandboxed read-only run tool for the planner #3242

Closed

Description

@dan-petty

Problem

The largest class of plan defects is a false premise that only a command run can show: 8 of 48 findings in the first five plan fixes. Examples: devops --dry-run config unset deletes a key (#3218), a help text shows a form that the tool refuses (#2743), a report excludes LOW (#2646). The planner reads files and cannot run a command. The model pass of #3182 reads text and runs nothing.

A run tool is a risk. In the plan fixes, devops --dry-run config unset deleted a key and wrote a backup. A tool that runs commands in the job must not touch the checkout, the cluster, the network or a secret.

Proposed change

Write the design first, as an ADR and a plan, and wait for a person to approve it. Do not build the tool before the approval.

The design answers these questions:

  1. Allow-list. Which commands run: devops <read command> --help, and devops read commands that the exposure table marks read-only with no path option (see fix(mcp): pr_check_readiness is read-only in the exposure table but can resolve threads #3235 and fix(mcp): read-only tools take paths that reach the server file system #3236), and the repro that the issue gives?
  2. Isolation. A temporary HOME, a copy of the config with no credential, a read-only copy of the staged commit, no network (a network policy of the Job or an unshared network namespace), a memory and time cap, a non-root user, and no service account token.
  3. Output. The answer is cut and masked, and is quoted into ## Feasibility by the planner.
  4. Open tools. Name the sandbox tools that exist (for example bubblewrap, nsjail, gVisor, the runner image) and the cost to build and keep one (SECURITY.md rule 3).
  5. Where it runs. In the stage Job, or in a separate Job that the stage Job asks for.
  6. Proof. A test that a command cannot write outside the sandbox, read a secret or open a connection.

Acceptance criteria

  1. An ADR in docs/adr/ states the decision, the alternatives and the rejected options.
  2. A person has approved it in a comment on this issue.
  3. The follow-up implementation issues exist and name this ADR.

Related: #3238, #3218, #3235, #3236, #3207.

Scope from #3288

These criteria replace criteria 2 and 3 above.

  • Criterion 2. A person merges the pull request that adds the ADR under docs/adr/. This merge is the approval. A merge of the plan pull request does not approve the ADR. A person asks for changes in the review of the ADR pull request.
  • Criterion 3. The follow-up implementation issues exist and name this ADR. Each follow-up issue lists docs(security): design a sandboxed read-only run tool for the planner #3242 as a dependency, or it is filed only after the merge. So the Service does not build the tool before the approval. The Service refines and stages open issues by itself, and the refined design files the follow-up issues inside the ADR, before the merge.
  • Record. The ADR states that the merge is the approval. The merge record replaces the approving person and the comment URL in the Status section.

Add these inputs to the design questions:

  • Where it runs. No stage Job exists. The plan runs in the Service pod (src/devops_cli/roadmap/run.py:555-572). The refined design chooses HostSandbox in a "stage Job" and rejects a command on the Service, so the ADR must answer this again.
  • The sandbox tool. k8s/devops/roadmap-service/deployment.yaml:47 sets seccompProfile, and feat(roadmap): run the implement agent shell in a real sandbox #2695 reports that unshare --user fails under RuntimeDefault. bwrap is in NOT_IN_RUNNER (src/devops_cli/roadmap/runner_tools.py:226). Nobody ran bubblewrap in that pod, so its failure there is unverified.
  • The decision on feat(roadmap): run the implement agent shell in a real sandbox #2695. The ADR takes the owner decision of 2026-10-30 as an input: privilege separation by container, with bubblewrap and unshare rejected. The owner comment of 2026-11-01 adds kubernetes-sigs/agent-sandbox as a candidate to measure, and that question stays open. This item does not change feat(roadmap): run the implement agent shell in a real sandbox #2695.

Proposed design

Problem statement

The planner reads files and cannot run a command. So a plan can rest on a false premise that only a run shows: 8 of 48 findings in the first five plan fixes. A run tool is a risk, because a command that looked read-only deleted a key (#3218). This item writes the ADR that designs a sandboxed, read-only run tool and lists the follow-up issues that build it. The approval of the ADR is #3288, and this item does not wait on it.

Acceptance criteria

Requirement: ADR file

The change SHALL add one ADR under docs/adr/ that records the decision, the alternatives and the rejected options for the sandboxed read-only run tool.

Scenario: The ADR file holds its sections

  • WHEN A check reads the new file in docs/adr/ after the change merges.
  • THEN The file holds a Decision section, an Alternatives section and a Rejected options section, and each section holds text.

Requirement: Closed allow-list

The ADR SHALL define the allow-list as devops --help for every command and the commands that the MCP exposure table marks read-only and that take no path option.

Scenario: The allow-list names the exposure table and refuses every other command

  • WHEN A check reads the allow-list section of the ADR.
  • THEN The section names the exposure table as the source of the read-only commands and refuses every command that is not on the list, including a command that an issue quotes.

Requirement: Isolation controls

The ADR SHALL require a temporary HOME, a copy of the config with no credential, a read-only copy of the staged commit, no network, a memory and time cap, a non-root user and no service account token.

Scenario: The ADR lists each control and the container boundary

  • WHEN A check reads the isolation section of the ADR.
  • THEN The section names each of the seven controls and states that a container with the RuntimeDefault seccomp profile applies them.

Requirement: Run location

The ADR SHALL state that the command runs in a separate Kubernetes Job that the planner creates for one run, and it MUST refuse the Service pod and the planner process.

Scenario: The ADR names the run Job and refuses the Service pod

  • WHEN A check reads the run-location section of the ADR.
  • THEN The section names the separate run Job and gives a reason to refuse the Service pod and the planner process.

Requirement: Cut and masked output

The ADR SHALL cap the command output, mask each secret in it and quote it into ## Feasibility.

Scenario: The ADR states the cap and the mask

  • WHEN A check reads the output section of the ADR.
  • THEN The section states the byte cap, the line cap and the mask function, and it names ## Feasibility as the place of the quote.

Requirement: Sandbox tools compared

The ADR SHALL compare bubblewrap, nsjail, gVisor and kubernetes-sigs/agent-sandbox, state what each tool lacks and state the cost to build and keep a sandbox.

Scenario: The comparison of the sandbox tools

  • WHEN A check reads the alternatives section of the ADR.
  • THEN The section names each tool, states what each tool lacks, and states the cost of the chosen option and the cost of a sandbox built from scratch.

Requirement: The #2695 decision as an input

The ADR SHALL take the owner decision of 2026-10-30 as an input, which separates privilege by container and rejects bubblewrap and unshare, and it MUST state that #2695 owns the measurement of kubernetes-sigs/agent-sandbox.

Scenario: The ADR records the #2695 input and the open measurement

Requirement: Proof tests

The ADR SHALL specify one test that a command cannot write outside the sandbox, one test that it cannot read a secret and one test that it cannot open a connection.

Scenario: The proof section names the three tests

  • WHEN A check reads the proof section of the ADR.
  • THEN The section names the test file and one test for each of the three cases.

Requirement: Follow-up issues

The ADR SHALL list the follow-up implementation issues in a Follow-ups section, and each listed issue SHALL name the ADR.

Scenario: The Follow-ups section lists the issues

  • WHEN A check reads the Follow-ups section of the ADR.
  • THEN The section lists at least one issue number, and the body of each listed issue names the ADR.

Requirement: Approval record

The ADR SHALL state that the merge of its pull request is the approval, and it MUST record the merge commit in its Status section instead of an approving person and a comment URL.

Scenario: The Status section records the merge

  • WHEN A check reads the Status section of the ADR.
  • THEN The section names the merge commit as the record of the approval, and it holds no approving person and no comment URL.

Existing Tool Considered

No alternatives check has run on this issue. kubernetes-sigs/agent-sandbox is the open, maintained candidate that the owner named on 2026-11-01. #2695 owns its measurement, and no image here installs it, so the repository holds no measurement. bubblewrap is open and maintained, and HostSandbox wraps it. The owner decision of 2026-10-30 rejects bubblewrap for this path, and NOT_IN_RUNNER leaves it out of the runner image. nsjail and gVisor cover more, but no image here installs them. The change builds no sandbox: it adds one Job manifest and a thin runner. That code costs about 3,000 tokens to write, about 500 tokens a month to keep and one day of elapsed time. A sandbox built from scratch costs about 40,000 tokens and about two weeks.

Key questions

  • Which commands may the run tool execute?: The allow-list holds two forms. The first form is devops --help for every command. The second form is a devops command that the MCP exposure table marks read-only and that takes no path option. The tool builds the list at start from the CLI command tree and the exposure table. No other command runs. A command that an issue or a model quotes does not run. (best practice) [sources: SECURITY.md, src/devops_cli/ai/mcp/roles.py, src/devops_cli/ai/mcp/generator.py]
  • What confines the command, now that bubblewrap and unshare are rejected?: Privilege separation by container confines the command, as the owner decision of 2026-10-30 for feat(roadmap): run the implement agent shell in a real sandbox #2695 requires. The run pod uses UID 1000 and the RuntimeDefault seccomp profile. It mounts no service account token. Its NetworkPolicy admits no egress. A CPU, memory and wall-clock cap bounds it. It gets a temporary HOME on an emptyDir, a copy of the config with no credential, and a read-only copy of the staged commit. (best practice) [sources: SECURITY.md, k8s/devops/roadmap-service/deployment.yaml, k8s/devops/roadmap-service/networkpolicy-egress.yaml, k8s/devops/roadmap-service/serviceaccount.yaml, src/devops_cli/roadmap/runner_tools.py, CONTEXT.md]
    • Chosen: Privilege separation by container. The owner decision of 2026-10-30 for feat(roadmap): run the implement agent shell in a real sandbox #2695 takes it, and the platform gives it without new code.
    • Rejected: HostSandbox with bubblewrap. The owner decision rejects bubblewrap and unshare, and NOT_IN_RUNNER leaves bwrap out of the runner image.
    • Rejected: A NetworkPolicy alone. It stops egress only and leaves the filesystem, the HOME and the environment open.
    • Rejected: nsjail or gVisor. No image here installs them, and gVisor needs a runtime class on the cluster.
  • Where does the command run: in the Service pod, in a stage Job, or in a separate run Job?: The command runs in a separate Kubernetes Job that the planner creates for one run. The Service pod holds the App private key and runs the lanes, so a model-driven command does not run there. The planner process does not run it either. No stage Job exists today. (best practice) [sources: CONTEXT.md, docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md, src/devops_cli/roadmap/run.py, SECURITY.md]
    • Chosen: A separate run Job. It gives the container boundary, holds no service account token and keeps the App private key away from the command.
    • Rejected: The Service pod, in the planner process. The Service pod holds the App private key and runs the lanes, and src/devops_cli/roadmap/run.py runs the plan there.
    • Rejected: A stage Job. No stage Job exists, so the ADR cannot put the command in one.
  • How is the output cut and masked before the planner quotes it?: The tool cuts stdout and stderr at a byte cap and a line cap. It passes the text through mask_secrets. The planner quotes the command, the exit code and the cut text under ## Feasibility, with a note that names the cap. (best practice) [sources: SECURITY.md, src/devops_cli/sandbox/host.py, CONTEXT.md]
    • Chosen: A byte cap, a line cap and mask_secrets. The cap keeps the planner within its budget, and the mask keeps a credential out of the plan, as SECURITY.md rules 1 and 12 require.
    • Rejected: The full output. It floods the planner budget and can carry a credential or a private address.
    • Rejected: A model summary of the output. A model adds a claim that no run made, which is the class of defect that this item removes.
  • Which open sandbox tools exist, and what does each cost to build and keep?: bubblewrap is open and maintained, and HostSandbox wraps it, but NOT_IN_RUNNER leaves it out of the runner image and the owner decision of 2026-10-30 rejects it here. nsjail and gVisor cover more, but no image here installs them, and gVisor needs a runtime class. kubernetes-sigs/agent-sandbox is the open candidate that the owner named on 2026-11-01, and feat(roadmap): run the implement agent shell in a real sandbox #2695 owns its measurement. The chosen option is the container boundary, which the platform provides, so the change builds no sandbox. The thin run Job costs about 3,000 tokens to write, about 500 tokens a month to keep and one day of elapsed time. A sandbox built from scratch costs about 40,000 tokens and about two weeks. (best practice) [sources: SECURITY.md, src/devops_cli/sandbox/host.py, src/devops_cli/roadmap/runner_tools.py, tests/sandbox/test_host_sandbox.py]
    • Chosen: The container boundary of the run Job. The platform provides it, and the owner decision of 2026-10-30 takes privilege separation by container.
    • Rejected: bubblewrap (bwrap). The owner decision rejects it here, and the runner image leaves it out.
    • Rejected: nsjail. No image here installs it, and the container boundary already gives the limits that the tool needs.
    • Rejected: gVisor (runsc). It needs a runtime class on the cluster and a second kernel path, which exceeds the need.
    • Rejected: kubernetes-sigs/agent-sandbox. The owner named it as a candidate to measure, and feat(roadmap): run the implement agent shell in a real sandbox #2695 owns that measurement, so this ADR records it as an open question and does not adopt it.
    • Rejected: Build our own sandbox. The platform already gives the container boundary, so new sandbox code adds a second path to keep.
  • Which tests prove that a command cannot write outside the sandbox, read a secret or open a connection?: The ADR names three tests in tests/roadmap/test_run_job_manifest.py. One test writes outside the read-only copy of the staged commit. One test reads a credential path and the service account token. One test opens a connection. Each test reads the rendered Job manifest offline, and a live test marked k8s runs the same three cases against a real Job. (best practice) [sources: tests/sandbox/test_host_sandbox.py, k8s/devops/roadmap-service/networkpolicy-egress.yaml, k8s/devops/roadmap-service/serviceaccount.yaml]
    • Chosen: Manifest tests offline and one live test marked k8s. The manifest test runs offline in the gate, and the live test proves the pod, the token mount and the network policy.
    • Rejected: A unit test with a fake executor. It never starts a pod, so it proves nothing about the token mount or the network policy.
    • Rejected: The bubblewrap suite in tests/sandbox/test_host_sandbox.py. It proves the host sandbox, and the owner decision rejects bubblewrap for this path.
    • Rejected: A live cluster test only. It needs a cluster, so it cannot check the manifest offline.
  • How does the ADR record the approval?: The merge of the pull request that adds the ADR is the approval. The ADR states this in its Status section, which records the merge commit. The section holds no approving person and no comment URL. A person asks for changes in the review of that pull request. (best practice) [sources: docs/adr/0004-ci-is-the-authoritative-gate.md, docs/adr/0014-required-checks-gate-the-merge-and-the-pre-push-hook-runs-the-fast-static-checks.md, CONTEXT.md]
    • Chosen: The merge of the ADR pull request. It needs no person to comment on a schedule, and the required checks gate it.
    • Rejected: A comment of approval on this issue. It leaves no gate, and it waits for a person to answer on a schedule.
    • Rejected: An approval label. It records no review and no merge.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-06: not-applicable.
Class: docs, no search.
Tool: none found.

Activity

  1. added
    type/docs
    scope/security
    status/new
    value/medium
    effort/low
    on Nov 2, 2026
  2. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/docs. The docs prefix of the title gives the type.
    • Scope: scope/security. The (security) scope of the title gives the scope.
    • Priority: P2-Medium. It is a prerequisite for a security-sensitive feature but is not an active incident or blocking defect.
    • Value: Medium. It unblocks a future implementation and documents security decisions, but delivers no direct user-facing change.
    • Effort: Low. The work is writing one ADR, listing alternatives, and creating follow-up issues; no code is written.
    • Related: feat(roadmap): the stage job plans with a read-only investigation toolbox #3037, which asks for a different change. Both extend the planner's capabilities; #3037 adds read-only file inspection tools, while this candidate designs a sandboxed command execution tool.
  3. added
    priority/p2-medium
    status/ready
    and removed
    status/new
    on Nov 2, 2026
  4. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at dc26693 (see proposed design in issue body).

    Moved to new items: #3288.

  5. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    The stage job returned the item to New. The premise of the issue does not hold at the staging commit, so the job planned no change and opened no pull request.

    Evidence:

    placeholder

  6. added
    status/new
    status/ready
    and removed
    status/ready
    status/new
    on Nov 2, 2026
  7. 6 remaining items

  8. added
    status/in-review
    and removed
    status/in-progress
    on Nov 7, 2026
  9. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Pull request #3958 is ready for review. The checks passed.

    Spend: 186 model requests, 14370815 input tokens, 81759 output tokens.

  10. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261107-093414-cf84 ended: succeeded.
    Image digest: sha256:a12d8a3601a2f9803ba6a7f77fe19fdcc27a4de30944a1e65fc19d08808e9eff

    The last lines of its log:

    Tool call: shell, program uv, ok.
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops install-tools --help
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops install-tools --tool actionlint ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: grep -rn plan-check.md tests src | ...
    Tool call: shell, started: uv run devops ci --check --only ...
    Tool call: shell, program grep, ok.
    Tool call: shell, program uv, ok.
    Tool call: shell, started: grep -n <masked> -A 40 src/devops_cli/commands/pr.py ...
    Tool call: shell, program grep, ok.
    Tool call: shell, started: git diff
    Tool call: shell, program git, ok.
    Tool call: shell, started: uv run devops ci --only openspec
    Tool call: shell, started: uv run ast-grep test --skip-snapshot-tests
    Tool call: shell, program uv, ok.
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci test tests/invariants
    Tool call: shell, program uv, ok.
    Tool call: shell, started: tail -60 /home/devops/.data/agent/worktrees/w-3242/.pydantic-ai-harness/shell/d02a8e5d2f5544038a9411402de051e3/output.log
    Tool call: shell, program tail, ok.
    Tool call: shell, started: cat /home/devops/.data/agent/worktrees/w-3242/.pydantic-ai-harness/shell/d02a8e5d2f5544038a9411402de051e3/status.json
    Tool call: shell, program cat, ok.
    Tool call: shell, started: other
    Tool call: shell, program other:924ebe2c8489, refused.
    Tool call: shell, started: uv run python -c <masked>
    Tool call: shell, program uv, refused.
    Tool call: shell, started: uv run python -c <masked>
    Tool call: shell, program uv, refused.
    Tool call: shell, started: uv run python -c __import__('time').sleep(40)
    Tool call: shell, program uv, ok.
    Tool call: shell, started: tail -40 /home/devops/.data/agent/worktrees/w-3242/.pydantic-ai-harness/shell/d02a8e5d2f5544038a9411402de051e3/output.log
    Tool call: shell, program tail, ok.
    Tool call: shell, started: git status --porcelain=<masked>
    Tool call: shell, started: git diff --stat
    Tool call: shell, program git, ok.
    Tool call: shell, program git, ok.
    ✓ Took 1 item(s) to a ready pull request, stopped 0.
    Elapsed: 49m 48s
    
  11. removed
    owner/service
    on Nov 7, 2026
  12. removed
    status/in-review
    on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/securitytype/docsvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions