Skip to content

reservedSandboxKeys only guards env.sandbox, not .env.d or host_files dest #7010

Open

Description

@waynesun09

reservedSandboxKeys is consulted only by buildSandboxEnvLines (internal/cli/run.go), so it stops a harness env.sandbox entry shadowing a runner-owned export and nothing else. Two other harness-controlled routes reach the same variables.

First, bootstrapEnv sources .env.d/*.env partway through the generated script, so any host_files entry with expand: true landing a file there overwrites every export written above that line. FULLSEND_ROLE and FULLSEND_SLUG are written above it today.

Second, host_files entries have an unvalidated dest, and .env is uploaded before them, so dest: /sandbox/workspace/.env replaces the runner's file wholesale regardless of ordering.

This is trusted harness config rather than an untrusted-input path — the harness is as trusted as the runner invoking it — so the impact is that the reserved-key guarantee is narrower than it reads, not that an attacker gets in.

Proposed change

Either source harness-controlled files before every runner-owned export, or reject a host_files dest that targets the runner's own .env.

Validation criteria

A harness that sets FULLSEND_ROLE through an .env.d file, and one that targets /sandbox/workspace/.env with host_files, both fail or are ignored rather than replacing the runner's value.

Context

Found while reviewing #7007, which moved that PR's two run facts below the .env.d line and closes the first route for those two keys only. The general gap remains.

Activity

  1. fullsend-ai-triage commented on Sep 4, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 2:57 PM UTC · Completed 3:01 PM UTC

    Commit: fecb2f0 · View workflow run →

    Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $0.80

  2. added
    type/bug
    component/sandbox
    component/runner
    priority/medium
    ready-to-code
    on Sep 4, 2026
  3. fullsend-ai-triage commented on Sep 4, 2026

    @fullsend-ai-triage

    Related issues:

    Proposed test case:

    // TestReservedKeysNotOverriddenByEnvD verifies that .env.d files
    // cannot shadow runner-owned infrastructure variables.
    func TestReservedKeysNotOverriddenByEnvD(t *testing.T) {
        // Build a harness with a host_files entry that lands
        // FULLSEND_ROLE=attacker in .env.d/override.env
        // Call bootstrapEnv and assert FULLSEND_ROLE retains
        // the runner-set value, not the .env.d value.
    }
    
    // TestHostFilesDestRejectsRunnerEnvPath verifies that host_files
    // cannot target the runner's own .env file.
    func TestHostFilesDestRejectsRunnerEnvPath(t *testing.T) {
        // Build a harness with host_files dest: /sandbox/workspace/.env
        // Assert bootstrapEnv returns an error or ignores the entry.
    }

    Labels: Sandbox env var guard bypass via .env.d and host_files is a confirmed runner/sandbox defect with limited impact (trusted config only).


    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
  4. fullsend-ai-coder commented on Sep 4, 2026

    @fullsend-ai-coder
    Contributor

    🤖 Finished Code · ✅ Success · Started 3:03 PM UTC · Completed 3:23 PM UTC

    Commit: fecb2f0 · View workflow run →

    Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $7.00

  5. fullsend-ai-scribe commented on Sep 22, 2026

    @fullsend-ai-scribe

    Meeting update — 2026-09-22

    Relevant to this issue: A bug was identified where runner credentials in environment files shadow placeholder tokens injected by providers into the sandbox — directly related to this issue's concern about .env.d and host_files bypassing reservedSandboxKeys.

    • A bug was identified where runner credentials in .env files shadow placeholder tokens that providers inject into the sandbox
    • Proposal to document that sandbox configuration should exclude sensitive tokens and rely on providers for credential injection
    • Proposal to improve process isolation by explicitly defining environment variables in maps rather than inheriting them from the runner process

    Related PRs: #7012 (guard reserved sandbox keys against .env.d and host_files bypass), #7192 (preserve workflow token for GitHub Packages providers)

    Next steps: Review PR #7012 for removing tokens from sandbox blocks. Update documentation to specify that the sandbox should not contain sensitive information and that providers should be used for credential injection.

    Meeting notes

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

    bugcomponent/runnercomponent/sandboxpriority/mediumready-to-codetype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions