Skip to content

fix(#8498)!: read the agent-writable .env as data at launch - #8565

Merged
waynesun09 merged 7 commits into
mainfrom
agent/8498-env-as-data
Oct 19, 2026
Merged

waynesun09 merged 7 commits into
mainfrom
agent/8498-env-as-data

Conversation

@fullsend-ai-coder

@fullsend-ai-coder fullsend-ai-coder Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The Claude Code, codex and pi launches no longer source the agent-writable /sandbox/workspace/.env as shell. A pinned, isolated python3 reads it, and the .env.d files and iteration.env it names, as NAME=value data. The launch shell then evals only the loader's single-quoted export lines. Before this change, code in .env ran before the launch checks finished, so it could rewrite a hook and exec the CLI itself.

Related Issue

Also closes #7580: pi no longer receives LD_PRELOAD, LD_LIBRARY_PATH or LD_AUDIT from .env.

Changes

  • internal/runtime/env_data.go (new): envDataLoad pins python3 the same way the CLIs are pinned (binaryPin) and runs it with -I -S.
    • Accepted: [export ]NAME=value (quoted values, multi-line quotes, $NAME / ${NAME}, a leading ~), export NAME, comments, and the four runner-written control lines (EnvDataControlLines: PATH capture and restore, the .env.d loop, iteration.env), which it interprets as data.
    • Ignored: everything else (command substitution, functions, exec, ., readonly, ;-joined commands, other parameter expansions). A warning names the file and line number but never the content.
    • Never taken from .env, for any runtime: LD_PRELOAD, LD_LIBRARY_PATH, LD_AUDIT, IFS, and each launch's read-only pins (FULLSEND_CLAUDE_BIN, FULLSEND_GATEWAY_PLACEHOLDER, FULLSEND_CODEX_BIN, the codex PATH pin, FULLSEND_PI_BIN). A write to a pin would otherwise abort the launch shell.
  • claude_integrity.go, codex_run.go, pi_run.go: . .env is replaced by envDataLoad. The existing post-.env unsets and second guard passes are kept as a second layer.
  • Claude: [ is added to the post-.env unset -f list, matching pi_run.go.
  • internal/cli/run_test.go: new TestEnvDataControlLinesMatchRunner keeps the lines bootstrapEnv writes in step with the lines the loader recognizes.
  • Docs: harness reference (.env.d host files), customizing-agents, docs/runtimes/claude.md, and a new security-matrix row in runtime-implementation.md.

Breaking change

On Claude, codex and pi runs, .env / .env.d/*.env lines other than assignments, export NAME and comments no longer run at launch; they are ignored with a warning. The fleet's .env.d files are plain export NAME=value lines, which keep working, as do the agent's own .env writes (for example a PATH prepend).

Design notes / open points for review

  • The issue suggested starting the CLI "in a clean environment". This PR keeps the sandbox exec environment, which is where OpenShell injects provider placeholders, and only removes .env as a code path. env -i would drop those placeholders.
  • The loader needs python3 in the sandbox image. The image already ships it for the hook scripts and codex. A custom image without it now fails the launch with python3 not found on PATH (exit 127).
  • OpenCode is not named in the issue body and still sources .env. Triage flagged the same pattern there, so it is a follow-up candidate.
  • ADR 0100 gets a short dated implementation note (no change to its decision); the launch-check semantics are recorded in the security feature matrix.

Testing

  • New internal/runtime/env_data_test.go runs the real loader under /bin/sh. Cases:
    • the triage-proposed hostile .env (command substitution, backticks, functions, exec, alias, readonly, LD_* exports, a pin write, plus a legitimate PATH prepend): nothing executes, LD_* never reaches the CLI, and the PATH prepend survives;
    • a runner-shaped .env with .env.d files and iteration.env;
    • the value grammar, rejected forms, export NAME semantics, and a missing .env.
  • Launch tests that relied on .env executing (hook rewrite between the guard passes, a sha256sum function, gateway readonly and placeholder overrides) now assert that the .env code does not run and that the runner's values win. TestBuildPiRunCommand_LoaderEnvHygiene now covers LD_* for pi. The codex golden files are regenerated.
  • go test ./internal/runtime/ passes except TestBuildRunCommand_ClaudeMissingExits127, which also fails on main in the agent sandbox because a real /usr/bin/claude exists there. Patch coverage of the changed Go lines is 100%.
  • make lint: pre-commit could not fetch its remote hook repos (TLS error in the sandbox). gofmt, go vet, lint-docs-links, lychee --offline, whitespace/EOL checks and scan-secrets were run directly and pass.

Checklist

  • PR title follows Conventional Commits (! for the breaking change)
  • Commits are signed off (DCO): not applicable, autonomous agent commit

🤖 Generated with Claude Code


Closes #8498

Post-script verification

  • Branch is not main/master (agent/8498-env-as-data)
  • Secret scan passed (gitleaks — af8cd4756172ec105c3aa523515c9c7d51684e90..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

@fullsend-ai-review

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Ended 2:03 PM UTC

Commit: 04d7a08 · View workflow run →

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 2:04 PM UTC · Completed 2:22 PM UTC

Commit: 04d7a08 · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $4.35

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Site preview

Preview: https://59cb2cbc-site.fullsend-ai.workers.dev

Commit: 7ab89dcb4bcab22d53af9eed981f1ac6771c980e

@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Oct 19, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

<!-- fullsend:risk-assessment -->
Risk Assessment: moderate (2/5)

Details

High churn and change coupling across runtime launch paths, security labels, and unflagged launch behavior modification elevate risk to moderate despite bot authorship, zero protected paths, and strong test coverage.

Previous run

<!-- fullsend:risk-assessment -->
Risk Assessment: moderate (2/5)

Details

High churn and change coupling across runtime launch paths, security labels, and unflagged launch behavior modification elevate risk to moderate despite bot authorship, zero protected paths, and strong test coverage.

Previous run (2)

<!-- fullsend:risk-assessment -->
Risk Assessment: moderate (2/5)

Details

High churn and change coupling across runtime launch paths, security labels, and unflagged launch behavior modification elevate risk to moderate despite bot authorship, zero protected paths, and strong test coverage.

Previous run (3)

<!-- fullsend:risk-assessment -->
Risk Assessment: moderate (2/5)

Details

High churn and file coupling across runtime launch paths, security labels, and unflagged launch behavior modification elevate risk to moderate despite strong test coverage and bot authorship.

Previous run (4)

<!-- fullsend:risk-assessment -->
Risk Assessment: moderate (2/5)

Details

High churn and file coupling across runtime launch paths, security labels, and unflagged launch behavior modification elevate risk to moderate despite strong test coverage and bot authorship.

Previous run (5)

<!-- fullsend:risk-assessment -->
Risk Assessment: moderate (2/5)

Details

High churn and file coupling across runtime launch paths, security labels, and unflagged launch behavior modification elevate risk to moderate despite strong test coverage and bot authorship.

Previous run (6)

<!-- fullsend:risk-assessment -->
Risk Assessment: moderate (2/5)

Details

High churn and file coupling across runtime launch paths, security labels, and unflagged launch behavior modification elevate risk to moderate despite strong test coverage and bot authorship.

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Looks good to me

Earlier findings

  • f_f5866325a47539c8 — resolved_by_change: docs/runtimes/opencode.md now has a "Behaviour differences worth knowing" entry stating that OpenCode still sources .env as shell, linking to the security feature matrix.
  • f_a5cbbc6a5d075e91 — reclassified (low → info): the .env grammar, drop list, python3/exit-127 requirement and the OpenCode difference are now documented in the harness reference and runtime docs, and the breaking change is declared with ! and a BREAKING CHANGE footer. The only remaining gap is that docs/runtimes/claude.md does not state the python3 image requirement.
Previous run

<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6Im1pc3NpbmctZG9jIiwiZmlsZSI6ImRvY3MvcnVudGltZXMvb3BlbmNvZGUubWQiLCJpZCI6ImZfZjU4NjYzMjVhNDc1MzljOCIsImxpbmUiOjEyMCwiYWN0aW9uYWJsZSI6dHJ1ZX0seyJzZXZlcml0eSI6ImxvdyIsImNhdGVnb3J5IjoiYmFja3dhcmQtaW5jb21wYXRpYmxlIiwiZmlsZSI6ImludGVybmFsL3J1bnRpbWUvZW52X2RhdGEuZ28iLCJpZCI6ImZfYTVjYmJjNmE1ZDA3NWU5MSIsImFjdGlvbmFibGUiOmZhbHNlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJlZGdlLWNhc2UiLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9lbnZfZGF0YS5nbyIsImlkIjoiZl80NTkzZTdjY2IxODVkYjZhIiwibGluZSI6MjU5LCJhY3Rpb25hYmxlIjpmYWxzZX0seyJzZXZlcml0eSI6Im1lZGl1bSIsImNhdGVnb3J5IjoiaW5qZWN0aW9uLXZ1bG4iLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9waV9leHRlbnNpb24vZnVsbHNlbmQtaG9va3MuanMiLCJpZCI6ImZfNjk4MzEzY2E0MDI0NDk3YSIsImxpbmUiOjE4OSwiYWN0aW9uYWJsZSI6dHJ1ZX0seyJzZXZlcml0eSI6ImxvdyIsImNhdGVnb3J5IjoiaW5qZWN0aW9uLXZ1bG4iLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9waV9leHRlbnNpb24vZnVsbHNlbmQtaG9va3MuanMiLCJpZCI6ImZfMzgxMzA1ZjU1NjE1ZTJjMSIsImxpbmUiOjE4OSwiYWN0aW9uYWJsZSI6ZmFsc2V9LHsic2V2ZXJpdHkiOiJtZWRpdW0iLCJjYXRlZ29yeSI6ImluamVjdGlvbi12dWxuIiwiZmlsZSI6ImludGVybmFsL3J1bnRpbWUvZW52X2RhdGEuZ28iLCJpZCI6ImZfNzg3Y2U5MmEwMDdiNDg0YSIsImxpbmUiOjY4LCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJlZGdlLWNhc2UiLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9lbnZfZGF0YS5nbyIsImlkIjoiZl8zOTlhYzk4OWM0N2NlNWY1IiwibGluZSI6MjU3LCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJlZGdlLWNhc2UiLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9lbnZfZGF0YS5nbyIsImlkIjoiZl82MDQyNWI2NTViMTA3MjJhIiwibGluZSI6MjgwLCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJzdGFsZS1kb2MiLCJmaWxlIjoiZG9jcy9ndWlkZXMvZGV2L3RyYWNpbmcubWQiLCJpZCI6ImZfMjYxNWU0N2I4NTM1M2Y3MiIsImxpbmUiOjQwMiwiYWN0aW9uYWJsZSI6dHJ1ZX1dLCJkaXNwb3NpdGlvbnMiOlt7ImlkIjoiZl8yNjE1ZTQ3Yjg1MzUzZjcyIiwic3RhdHVzIjoicmVzb2x2ZWRfYnlfY2hhbmdlIn0seyJpZCI6ImZfZjU4NjYzMjVhNDc1MzljOCIsInN0YXR1cyI6Im9wZW4ifSx7ImlkIjoiZl9hNWNiYmM2YTVkMDc1ZTkxIiwic3RhdHVzIjoib3BlbiJ9LHsiaWQiOiJmXzY5ODMxM2NhNDAyNDQ5N2EiLCJzdGF0dXMiOiJkaXNtaXNzZWRfYnlfaHVtYW4ifSx7ImlkIjoiZl8zODEzMDVmNTU2MTVlMmMxIiwic3RhdHVzIjoiZGlzbWlzc2VkX2J5X2h1bWFuIn0seyJpZCI6ImZfNzg3Y2U5MmEwMDdiNDg0YSIsInN0YXR1cyI6ImRpc21pc3NlZF9ieV9odW1hbiJ9LHsiaWQiOiJmXzM5OWFjOTg5YzQ3Y2U1ZjUiLCJzdGF0dXMiOiJkaXNtaXNzZWRfYnlfaHVtYW4ifSx7ImlkIjoiZl82MDQyNWI2NTViMTA3MjJhIiwic3RhdHVzIjoiZGlzbWlzc2VkX2J5X2h1bWFuIn1dfQ== -->

Review

Findings

Low

  • [missing-doc] docs/runtimes/opencode.md:120 — The "Behaviour differences worth knowing" section does not say that OpenCode still sources /sandbox/workspace/.env as shell at launch. Claude Code, codex and pi now read it as data (Launch must not execute the agent-writable .env as shell (all runtimes) #8498).
    Remediation: Add an entry noting that OpenCode still sources .env as shell, unlike Claude Code, codex and pi (follow-up to Launch must not execute the agent-writable .env as shell (all runtimes) #8498).
  • [backward-incompatible] internal/runtime/env_data.go — The .env / .env.d/*.env contract changes from sourced shell to a restricted data grammar. Command substitution, ${X:-d} and functions are dropped with a stderr warning, and LD_*, PYTHON*, BASH_ENV, ENV and IFS are never taken from .env. Fleet repos that rely on those constructs get a different environment. The change is flagged with !, the PR body and a BREAKING CHANGE footer, and docs are updated. Advisory only: consider calling out the common dropped patterns in release notes and tracking the OpenCode follow-up.
  • [edge-case] internal/runtime/env_data.go:259 — The loader opens env files without newline="", so Python converts \r and \r\n inside quoted values to \n. Sourcing kept the original bytes. Byte-sensitive multiline values could change without a warning. New this round and advisory.
    Remediation: Pass newline="" to open() and add CR/CRLF regression cases in env_data_test.go.

Earlier findings

  • f_2615e47b85353f72 — resolved_by_change: on re-analysis docs/guides/dev/tracing.md:402 is still accurate. The runner still writes the iteration.env control line last in .env, and the loader reads iteration.env at that point.

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run (2)

<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJtZWRpdW0iLCJjYXRlZ29yeSI6ImluamVjdGlvbi12dWxuIiwiZmlsZSI6ImludGVybmFsL3J1bnRpbWUvcGlfZXh0ZW5zaW9uL2Z1bGxzZW5kLWhvb2tzLmpzIiwiaWQiOiJmXzY5ODMxM2NhNDAyNDQ5N2EiLCJsaW5lIjoxODksImFjdGlvbmFibGUiOnRydWV9LHsic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6ImluamVjdGlvbi12dWxuIiwiZmlsZSI6ImludGVybmFsL3J1bnRpbWUvcGlfZXh0ZW5zaW9uL2Z1bGxzZW5kLWhvb2tzLmpzIiwiaWQiOiJmXzM4MTMwNWY1NTYxNWUyYzEiLCJsaW5lIjoxODksImFjdGlvbmFibGUiOmZhbHNlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJzdGFsZS1kb2MiLCJmaWxlIjoiZG9jcy9ndWlkZXMvZGV2L3RyYWNpbmcubWQiLCJpZCI6ImZfMjYxNWU0N2I4NTM1M2Y3MiIsImxpbmUiOjQwMiwiYWN0aW9uYWJsZSI6dHJ1ZX0seyJzZXZlcml0eSI6ImxvdyIsImNhdGVnb3J5IjoibWlzc2luZy1kb2MiLCJmaWxlIjoiZG9jcy9ydW50aW1lcy9vcGVuY29kZS5tZCIsImlkIjoiZl9mNTg2NjMyNWE0NzUzOWM4IiwibGluZSI6MTIwLCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJiYWNrd2FyZC1pbmNvbXBhdGlibGUiLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9lbnZfZGF0YS5nbyIsImlkIjoiZl9hNWNiYmM2YTVkMDc1ZTkxIiwiYWN0aW9uYWJsZSI6ZmFsc2V9LHsic2V2ZXJpdHkiOiJtZWRpdW0iLCJjYXRlZ29yeSI6ImluamVjdGlvbi12dWxuIiwiZmlsZSI6ImludGVybmFsL3J1bnRpbWUvZW52X2RhdGEuZ28iLCJpZCI6ImZfNzg3Y2U5MmEwMDdiNDg0YSIsImxpbmUiOjY4LCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJlZGdlLWNhc2UiLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9lbnZfZGF0YS5nbyIsImlkIjoiZl8zOTlhYzk4OWM0N2NlNWY1IiwibGluZSI6MjU3LCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJlZGdlLWNhc2UiLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9lbnZfZGF0YS5nbyIsImlkIjoiZl82MDQyNWI2NTViMTA3MjJhIiwibGluZSI6MjgwLCJhY3Rpb25hYmxlIjp0cnVlfV0sImRpc3Bvc2l0aW9ucyI6W3siaWQiOiJmXzI2MTVlNDdiODUzNTNmNzIiLCJzdGF0dXMiOiJvcGVuIn0seyJpZCI6ImZfZjU4NjYzMjVhNDc1MzljOCIsInN0YXR1cyI6Im9wZW4ifSx7ImlkIjoiZl9hNWNiYmM2YTVkMDc1ZTkxIiwic3RhdHVzIjoib3BlbiJ9LHsiaWQiOiJmXzc4N2NlOTJhMDA3YjQ4NGEiLCJzdGF0dXMiOiJkaXNtaXNzZWRfYnlfaHVtYW4ifSx7ImlkIjoiZl8zOTlhYzk4OWM0N2NlNWY1Iiwic3RhdHVzIjoiZGlzbWlzc2VkX2J5X2h1bWFuIn0seyJpZCI6ImZfNjA0MjViNjU1YjEwNzIyYSIsInN0YXR1cyI6ImRpc21pc3NlZF9ieV9odW1hbiJ9XX0= -->

Review

Findings

Medium

  • [injection-vuln] internal/runtime/pi_extension/fullsend-hooks.js:189 — -E does not disable Python's user site. The loader accepts HOME, so an earlier iteration can plant HOME/.local/lib/pythonX.Y/site-packages/usercustomize.py (or a .pth file) that runs before the hook script and can exit 0 to skip the hook checks. The Claude launcher already uses -E -s -B (internal/security/hooks.go:225).
    Remediation: use ["-E", "-s", path] in runScript, update the fullsend-hooks.test.mjs argument assertion, and add a regression test with an attacker-controlled HOME.

Low

  • [injection-vuln] internal/runtime/pi_extension/fullsend-hooks.js:189 — Advisory, pre-existing: hook python3 is still resolved through the agent-controlled PATH, which envDataLoad accepts. The base code had the same gap and this PR narrows it. Better handled as a follow-up that pins an absolute hook interpreter and a trusted hook PATH.
  • [stale-doc] docs/guides/dev/tracing.md:402 — "The sandbox .env sources that file last" no longer holds for Claude, codex and pi, which read iteration.env as data (Launch must not execute the agent-writable .env as shell (all runtimes) #8498).
    Remediation: reword to say the launch reads iteration.env last (data on Claude/codex/pi, sourced on OpenCode).
  • [missing-doc] docs/runtimes/opencode.md:120 — "Behaviour differences worth knowing" does not say that OpenCode still sources .env as shell, unlike the other runtimes (Launch must not execute the agent-writable .env as shell (all runtimes) #8498).
    Remediation: add a bullet and link to the security matrix row in docs/contributing/runtime-implementation.md.
  • [backward-incompatible] internal/runtime/env_data.go — Intentional, documented break (! in the title): shell constructs in .env, .env.d/*.env and iteration.env are now ignored with a warning, python3 is required in the sandbox image, and the drop list now covers every PYTHON* variable.
    Remediation: add a release-note migration entry listing the unsupported constructs and the python3 requirement.

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run (3)

<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJtZWRpdW0iLCJjYXRlZ29yeSI6ImluamVjdGlvbi12dWxuIiwiZmlsZSI6ImludGVybmFsL3J1bnRpbWUvZW52X2RhdGEuZ28iLCJpZCI6ImZfNzg3Y2U5MmEwMDdiNDg0YSIsImxpbmUiOjY4LCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJlZGdlLWNhc2UiLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9lbnZfZGF0YS5nbyIsImlkIjoiZl8zOTlhYzk4OWM0N2NlNWY1IiwibGluZSI6MjU3LCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJlZGdlLWNhc2UiLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9lbnZfZGF0YS5nbyIsImlkIjoiZl82MDQyNWI2NTViMTA3MjJhIiwibGluZSI6MjgwLCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJzdGFsZS1kb2MiLCJmaWxlIjoiZG9jcy9ndWlkZXMvZGV2L3RyYWNpbmcubWQiLCJpZCI6ImZfMjYxNWU0N2I4NTM1M2Y3MiIsImxpbmUiOjQwMiwiYWN0aW9uYWJsZSI6dHJ1ZX0seyJzZXZlcml0eSI6ImxvdyIsImNhdGVnb3J5IjoibWlzc2luZy1kb2MiLCJmaWxlIjoiZG9jcy9ydW50aW1lcy9vcGVuY29kZS5tZCIsImlkIjoiZl9mNTg2NjMyNWE0NzUzOWM4IiwibGluZSI6MTIwLCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJiYWNrd2FyZC1pbmNvbXBhdGlibGUiLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9lbnZfZGF0YS5nbyIsImlkIjoiZl9hNWNiYmM2YTVkMDc1ZTkxIiwiYWN0aW9uYWJsZSI6ZmFsc2V9XX0= -->

Review

Findings

Medium

  • [injection-vuln] internal/runtime/env_data.go:68 — The Python startup denylist is incomplete. PYTHONWARNINGS and BROWSER are still taken from .env. PYTHONWARNINGS='ignore::antigravity.X' makes CPython import antigravity, which runs the BROWSER command. pi's hook adapter (pi_extension/fullsend-hooks.js) spawns python3 without -I or -E and with env: process.env, so the payload runs before the hook's checks. This was checked statically only. It is a residual gap rather than a regression, since the base launch sourced .env as shell.
    Remediation: Reject the whole PYTHON* namespace from agent-writable env files. Run pi's hook interpreter with -I or at least -E. Add a regression test.

Low

  • [edge-case] internal/runtime/env_data.go:257 — Files are opened with Python's default universal newlines, so a raw CR or CRLF inside a quoted value becomes LF. Sourcing the file would have kept the bytes.
    Remediation: Open with newline="" and add CR/CRLF round-trip tests.
  • [edge-case] internal/runtime/env_data.go:280 — Any OSError from listing .env.d is treated as "no directory". An unreadable .env.d silently drops every included setting, while an unreadable file correctly fails the launch.
    Remediation: Fail closed on listing errors other than a missing directory, and add an unreadable-directory test.
  • [stale-doc] docs/guides/dev/tracing.md:402 — "The sandbox .env sources that file last" is imprecise for the Claude, codex and pi launches, which now read iteration.env as data.
    Remediation: Reword to say the launch reads it last, as data.
  • [missing-doc] docs/runtimes/opencode.md:120 — "Behaviour differences worth knowing" does not say that OpenCode still sources .env and .env.d/*.env as shell.
    Remediation: Add that entry.
  • [backward-incompatible] internal/runtime/env_data.go — Shell forms such as ${VAR:-default}, $(cmd), A=1 B=2 and ;-joined commands in env files owned by other repos are now dropped with a warning, and the launch continues. The break is intentional and documented. Check known consumers such as fullsend-ai/agents before merge, and call it out in the release notes.

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run (4)

Review

Findings

Low

  • [shell-startup-injection] internal/runtime/env_data.go:64 — BASH_ENV and ENV are not in envDataDropNames, so an agent-written export BASH_ENV=... in .env still reaches the CLI environment and later Bash processes run that file first. This is not a regression: .env used to be sourced as shell, and the agent can already run its own scripts. It is still inconsistent with the loader dropping LD_* and PYTHON*, and with the harness env denylist (docs/reference/harness-reference.md:221), which names both variables.
    Remediation: add BASH_ENV and ENV to envDataDropNames, and add a test that an exported BASH_ENV in .env is dropped with a warning.
  • [stale-doc] docs/runtimes/codex.md:224 — the latest commit makes the loader also print plain (unexported) NAME='value' lines. Several places still say the launch evals "only the export lines": docs/runtimes/codex.md:224, the new ADR 0100 note (docs/ADRs/0100-codex-sandbox-hooks.md:69) and the comment at internal/runtime/env_data.go:101.
    Remediation: say "the assignment lines it prints".
  • [architectural-conflict] docs/ADRs/0100-codex-sandbox-hooks.md:67 — the PR adds a short "Implementation note" to accepted ADR 0100. docs/contributing/adrs.md allows minor annotations but requires that edits to accepted ADRs be called out in the PR description. The PR description says ADR 0100 "is immutable and is not edited", which contradicts the diff. (Prior finding, still open.)
  • [breaking-cli] internal/runtime/env_data.go:100 — .env and .env.d/*.env lines other than assignments, export NAME, comments and the four runner control lines are now ignored with a warning, and the launch needs python3. The change carries ! and the PR body states it, so this is intentional. Listing the dropped constructs and the python3 requirement in the migration notes would help fleet repos. (Prior finding, still open.)

Earlier findings

  • f_a1c4d5212e50f424 — resolved_by_change: the loader output loop in internal/runtime/env_data.go (the new loop near line 309) now emits non-exported assignments as plain shell variables. TestEnvDataLoad_NonExportedIsShellVariable covers it.
Previous run (5)

<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJtZWRpdW0iLCJjYXRlZ29yeSI6ImxvZ2ljLWVycm9yIiwiZmlsZSI6ImludGVybmFsL3J1bnRpbWUvZW52X2RhdGEuZ28iLCJpZCI6ImZfYTFjNGQ1MjEyZTUwZjQyNCIsImxpbmUiOjMwNiwiYWN0aW9uYWJsZSI6dHJ1ZX0seyJzZXZlcml0eSI6ImxvdyIsImNhdGVnb3J5IjoiYXJjaGl0ZWN0dXJhbC1jb25mbGljdCIsImZpbGUiOiJkb2NzL0FEUnMvMDEwMC1jb2RleC1zYW5kYm94LWhvb2tzLm1kIiwiaWQiOiJmX2M5ODkzN2YzYzVkM2RlYzYiLCJsaW5lIjo2NywiYWN0aW9uYWJsZSI6ZmFsc2V9LHsic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6ImJyZWFraW5nLWNsaSIsImZpbGUiOiJpbnRlcm5hbC9ydW50aW1lL2Vudl9kYXRhLmdvIiwiaWQiOiJmXzU5ZWIxMDQwM2Y2MDg1NzciLCJsaW5lIjoxMDAsImFjdGlvbmFibGUiOmZhbHNlfV19 -->

Review

Findings

Medium

  • [logic-error] internal/runtime/env_data.go:306 — The loader prints export lines only for names in exported (names already in the launch environment or marked with export). A plain NAME=value in .env is kept in values for in-file $NAME expansion but never reaches the launch shell. Under the old . .env, that assignment was a shell variable visible to later expansions in the same shell. Launch lines that run after the load still read such variables: pi_run.go:523 (GOOGLE_CLOUD_PROJECT="${ANTHROPIC_VERTEX_PROJECT_ID:-...}"), pi_run.go:544 (XAI_VERTEX_PROJECT_ID default chain) and codex_run.go:432 (RUST_LOG="${RUST_LOG:-info}"). When the name is absent from the initial environment and set without export, its value is now silently lost, although it is a plain assignment within the supported grammar.
    Remediation: Also emit safely quoted shell assignments (NAME='value') for accepted non-exported variables, and keep export lines for exported ones, so export attributes are preserved. Add a regression test that loads a non-exported variable and consumes it in a later launch-shell expansion.

Low

  • [architectural-conflict] docs/ADRs/0100-codex-sandbox-hooks.md:67 — This PR adds an implementation note to an accepted ADR, and docs/contributing/adrs.md requires edits to accepted ADRs to be called out in the PR description. The PR description still says "ADR 0100 is immutable and is not edited", which contradicts the diff.
    Remediation: Update the PR description to call out the ADR 0100 note and remove the stale statement.

  • [breaking-cli] internal/runtime/env_data.go:100 — The PR narrows the .env / .env.d/*.env contract. Downstream producers that write shell constructs ($(...), source, conditionals, ;-joined commands) will have those lines dropped with a stderr warning. LD_*, IFS and PYTHON* startup variables are dropped as well. The PR is marked breaking (!) and documents the change, but nothing checks downstream producers (for example fullsend-ai/agents scripts or org configs) ahead of release.
    Remediation: Before release, check known downstream producers for .env lines that are not plain assignments, export NAME or comments. Call out the change in the release notes. Optionally add a preflight lint.


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run (6)

Review

Findings

Medium

  • [error-handling] internal/runtime/env_data.go:279 — Read failures from iteration.env and .env.d files are silently discarded. read_file returns an OSError, but both recursive callers (the .env.d loop's read_file(p, False) and the iteration branch's read_file(iter_file, False)) ignore the return value, so the loader exits 0 and the launch proceeds with incomplete environment configuration. An existing but unreadable iteration.env loses the deadline, budget and TRACEPARENT without any diagnostic; unreadable .env.d files similarly lose their configuration. On base, . "$f" on an unreadable file ended the non-interactive sh, so this is a behavioural regression (fail-open on config loss).
    Remediation: Propagate errors from included files to the top-level failure handler and exit nonzero before emitting exports. Keep genuinely absent optional files acceptable (the isfile checks already do this), but treat permission and I/O failures as errors. Add failure-path tests for unreadable .env.d files and iteration.env.

  • [code-injection] internal/runtime/env_data.go:55 — The loader accepts PYTHONPATH, PYTHONHOME, PYTHONSTARTUP and PYTHONUSERBASE from .env and exports them (envDataDropNames covers only LD_, IFS and the loader's own variables). Claude and codex unset PYTHON after the load, but pi's post-load cleanup (piLoaderEnvUnset: NODE_/JITI_ only) does not. pi's hook adapter (internal/runtime/pi_extension/fullsend-hooks.js:187) runs spawn("python3", [path], {env: process.env}) without -I, so a .env-planted PYTHONPATH/sitecustomize.py runs before the digest-checked hook script and can forge an allow verdict without touching a protected file. This is pre-existing (base . .env allowed the same exports), but it leaves the gap open in a change whose purpose is hardening .env handling and whose stated goal includes dropping loader-affecting variables for pi.
    Remediation: Add the PYTHON* startup variables to envDataDropNames or to pi's post-load unset, and/or spawn the pi hook scripts with python3 -I (as codex's hooks.json already does). Add a pi regression test with an attacker-written sitecustomize.py.

  • [scope-truncation] internal/runtime/opencode_run.go:186 — Linked issue Launch must not execute the agent-writable .env as shell (all runtimes) #8498 is titled 'all runtimes' and triage put opencode in scope, but opencode_run.go:186 still runs && . <shellQuote(envFile)>, so opencode still executes the agent-writable .env as shell. The PR body raises opencode as an open point, but the commit message's rationale ('OpenCode is not named in the issue') contradicts the triage record, and no follow-up issue is linked.
    Remediation: Switch opencode_run.go to envDataLoad, or obtain explicit maintainer sign-off to defer it to a tracked follow-up issue and correct the rationale in the commit message and PR description.

  • [stale-doc] docs/guides/dev/cli-internals.md:486 — The Sandbox Lifecycle diagram's buildRunCommand() block shows . {envFile} &&; the Claude/codex/pi launches now use envDataLoad (pinned python3 -I -S parse + eval of exports). Lines 460/462 describe what bootstrapEnv writes into .env (still shell for the agent's own shells) and are not stale.
    Remediation: Replace . {envFile} && in the Exec() block with a description of the envDataLoad step (pin python3, parse .env as data, eval exports).

Low

  • [stale-doc] docs/cli/run.md:327 — The troubleshooting row says 'Runtimes that fullsend ships always source it [.env]'. Claude, codex and pi now read .env as data rather than sourcing it (OpenCode still sources). Line 389 ('before the agent-writable .env is sourced') uses similar wording.
    Remediation: Reword line 327 (and line 389) to 'load/read' rather than 'source'.

  • [missing-doc] docs/runtimes/codex.md:192 — docs/runtimes/claude.md was updated to explain that .env is read as data (python3 -I -S) and that LD_*/IFS/readonly pins are never accepted from .env; codex.md has no equivalent note.
    Remediation: Add a short note to codex.md matching the claude.md explanation.

  • [stale-doc] docs/runtimes/pi.md:817 — pi.md:817 says 'Files sourced from .env.d/ need export on each line.' On pi launches .env.d files are now parsed as data; the export advice still holds but 'sourced' is imprecise. Local pi run prerequisites do not mention python3 for the loader.
    Remediation: Reword 'sourced' at line 817 and mention python3 in the local pi run prerequisites.

  • [log-injection] internal/runtime/env_data.go:129 — warn() and the cannot-read message interpolate the file path unescaped. .env.d lives under the agent-writable /sandbox/workspace, so an agent-created .env.d filename containing newlines or :: workflow-command syntax, combined with an invalid line, can emit a forged line on launch stderr. Impact is limited to forged log/annotation lines (base could already write anything to the same stderr).
    Remediation: Render paths with repr() or another escaped single-line form, and add a test with a newline-bearing filename.

  • [documentation-coherence] docs/ADRs/0100-codex-sandbox-hooks.md:45 — Triage asked for the outcome to be recorded in ADR 0100. docs/contributing/adrs.md allows short notes on Accepted ADRs, and ADR 0100 already carries implementation notes that discuss .env, so a short Launch must not execute the agent-writable .env as shell (all runtimes) #8498 note is permitted and would keep the launch-check semantics discoverable.
    Remediation: Add a short Implementation note to ADR 0100 referencing Launch must not execute the agent-writable .env as shell (all runtimes) #8498.

  • [architectural-drift] docs/runtimes/claude.md:121 — docs/runtimes/claude.md:121 (a file this PR edits) still says 'A variable that .env makes readonly stops the launch rather than reaching Claude Code.' With envDataLoad, readonly lines are ignored with a warning (see TestBuildRunCommand_GatewayReadonlyIgnored), so the sentence is stale.
    Remediation: Reword line 121 to say readonly lines in .env are ignored by the data loader.

  • [code organization] internal/runtime/env_data.go:60 — const envDataRunnerPathVar sits outside the const ( block at line 47, right after var envDataDropNames, with no doc comment; the embedded loader script also hardcodes "FULLSEND_RUNNER_PATH" instead of deriving it from this constant.
    Remediation: Move it into the const block or give it its own doc comment.

  • [test conventions] internal/cli/run_test.go:4734 — In TestEnvDataControlLinesMatchRunner, lines[2] hardcodes an index into append(runnerPathLines(), harnessEnvLines(...)...), coupling the test to runnerPathLines() returning exactly two elements.
    Remediation: Replace lines[2] with harnessEnvLines(&harness.Harness{})[0].


Labels: PR changes the sandbox runtime launch path (Go) and related docs


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

fullsend-ai-review[bot]

This comment was marked as outdated.

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review fullsend-ai-review Bot added component/sandbox OpenShell sandbox environment go Pull requests that update go code labels Oct 19, 2026
@fullsend-ai-coder

fullsend-ai-coder Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 2:24 PM UTC · Completed 2:37 PM UTC

Commit: 04d7a08 · View workflow run →

Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.55

fullsend-ai-coder Bot added a commit that referenced this pull request Oct 19, 2026
Fail the launch when .env.d files or iteration.env exist but cannot be
read, drop PYTHONPATH/PYTHONHOME/PYTHONSTARTUP/PYTHONUSERBASE from .env,
and escape file paths in loader messages. Update stale docs (cli-internals,
run, claude, codex, pi), add an ADR 0100 implementation note, and tidy the
runner-path constant and a test index.

Disagreement: OpenCode still sources .env; moving it to the data loader is
left to a maintainer-approved follow-up.

Note: pre-commit could not fetch its hook repos (TLS error in the sandbox);
gofmt, go vet, lint-docs-links, git diff --check and scan-secrets passed.
TestBuildRunCommand_ClaudeMissingExits127 and some internal/cli tests fail
in this sandbox independent of this change.

Addresses #8565

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 Fix agent — iteration 1 (bot-triggered)

Addressed all findings except the OpenCode scope item, which is recorded as a disagreement pending maintainer sign-off. The loader now fails closed on unreadable included files, never takes Python startup variables from .env, and escapes paths in messages. Stale docs were corrected and an ADR 0100 note added. Pre-commit could not fetch hooks (TLS); gofmt, vet, docs link lint and secret scan passed. Remaining local test failures (TestBuildRunCommand_ClaudeMissingExits127 and some internal/cli fetch-service and post-script tests) are environment-related and not touched by this change.

Fixed (11):

  1. Read failures from .env.d files and iteration.env are silently discarded (internal/runtime/env_data.go): The loader now collects read errors from included files and exits nonzero before emitting any export, so an existing but unreadable .env.d file or iteration.env fails the launch. Added tests for both cases (skipped when running as root).
  2. PYTHONPATH/PYTHONHOME/PYTHONSTARTUP/PYTHONUSERBASE accepted from .env, reachable by pi's python3 hook adapter (internal/runtime/env_data.go): Added the four Python startup variables to envDataDropNames so they are never taken from .env for any runtime; codex golden files regenerated and a drop test added. Did not change pi's hook spawn to python3 -I, since the drop closes the .env path and the review allowed either remedy.
  3. Sandbox Lifecycle diagram still shows '. {envFile} &&' (docs/guides/dev/cli-internals.md): Replaced the line with the envDataLoad step (pinned python3 reads .env as data, eval of its exports).
  4. run.md says shipped runtimes 'source' .env (docs/cli/run.md): Reworded both places to 'load'.
  5. codex.md lacks the .env-as-data note present in claude.md (docs/runtimes/codex.md): Added a behaviour-differences bullet describing the data load, the never-taken names and the python3 requirement.
  6. pi.md says .env.d files are 'sourced' and omits python3 prerequisite (docs/runtimes/pi.md): Reworded to 'read' and added a python3 bullet to the local pi run prerequisites.
  7. Warnings and cannot-read messages interpolate unescaped file paths (internal/runtime/env_data.go): Paths are rendered with repr() in both messages; added a test with a newline-bearing .env.d file name.
  8. ADR 0100 has no note about the Launch must not execute the agent-writable .env as shell (all runtimes) #8498 outcome (docs/ADRs/0100-codex-sandbox-hooks.md): Added a short October 2026 implementation note referencing Launch must not execute the agent-writable .env as shell (all runtimes) #8498.
  9. claude.md still says a readonly .env variable stops the launch (docs/runtimes/claude.md): Reworded to say readonly lines are ignored with a warning; also listed the Python startup variables among never-taken names.
  10. envDataRunnerPathVar outside the const block and hardcoded in the loader script (internal/runtime/env_data.go): Moved it into the const block with a doc comment, and added a test that the loader script spells the same name.
  11. Test hardcodes lines[2] index (internal/cli/run_test.go): Replaced lines[2] with harnessEnvLines(&harness.Harness{})[0].

Disagreed (1):

  1. OpenCode still sources .env (scope truncation vs issue Launch must not execute the agent-writable .env as shell (all runtimes) #8498): Moving OpenCode to the data loader changes a separate launch path with its own read-only pins, post-.env restores and tests, and widens the breaking change to another runtime. That is a maintainer scope decision I cannot make or sign off on. A follow-up issue is recommended. I cannot amend the existing commit message or edit the PR description to correct the rationale, so a maintainer or human /fs-fix should do that.

Tests: passed

CI inspections (3):

  1. E2E Tests / behaviour (transient-infra, failure): A network stream was cancelled while the e2e harness uploaded scaffold files to a test repo; unrelated to this diff. Rerun the job.
  2. CI / test (passing, success)
  3. codecov/patch (passing, success)

Conflict update: skipped; strategy none; forge MERGEABLE; target main@af8cd4756172ec105c3aa523515c9c7d51684e90

Decision points
  • Whether to move OpenCode to the .env data loader in this PR (alternatives: Switch opencode_run.go to envDataLoad now, Defer to a tracked follow-up; rationale: It widens the breaking change to another runtime and needs maintainer sign-off, so it was left out.)

Next steps:

  • /fs-review — request a re-review of the changes
  • /fs-fix <your instruction> — run another fix pass with specific guidance
  • Push commits directly — review re-runs automatically on push
    Updated by fullsend fix agent

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 2:39 PM UTC · Completed 2:52 PM UTC

Commit: 4d5798f · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $3.20

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-coder

fullsend-ai-coder Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 2:54 PM UTC · Completed 3:06 PM UTC

Commit: 4d5798f · View workflow run →

Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.40

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 Fix agent — iteration 2 (bot-triggered)

Fixed the medium finding: the loader now keeps non-exported .env assignments as launch-shell variables, with a regression test and refreshed codex golden files. The two low findings are recorded as disagreements because they need a PR-description edit and a pre-release downstream audit, neither of which the fix agent can do. pre-commit could not fetch hook repositories, so the applicable hooks were run directly.

Fixed (1):

  1. Plain NAME=value assignments in .env never reach the launch shell, so later launch-line expansions lose them (internal/runtime/env_data.go): The loader now prints a quoted NAME='value' assignment for non-exported variables and keeps export for exported ones. Added a regression test where a plain variable is consumed by a later expansion and stays out of the environment. Regenerated the codex golden launch files, which embed the loader script.

Disagreed (2):

  1. PR description says ADR 0100 is not edited but the diff adds a note to it: The remediation is an edit to the PR description, which the fix agent cannot change (no PR mutations). No repository change is needed. The PR author should update the description to call out the ADR 0100 implementation note and drop the stale statement.
  2. Downstream .env producers not checked before release for lines that are not plain assignments: The remediation is a release-process check of downstream repositories and release notes, not a code change in this PR. The narrowed contract is already documented and the PR is marked breaking. A maintainer should audit downstream producers and add a release-notes entry before release.

Tests: passed

CI inspections (5):

  1. test (passing, success): Passed on the previous head.
  2. test-sandbox-darwin (passing, success): Passed on the previous head.
  3. commit-lint (passing, success)
  4. codecov/patch (passing, success)
  5. behaviour (pending, in_progress): E2E behaviour job was still running when inspected; no failure to diagnose.

Conflict update: skipped; strategy none; forge MERGEABLE; target main

Decision points
  • How to preserve non-exported assignments for later launch lines (alternatives: Emit plain NAME='value' lines for non-exported names, Export every accepted variable; rationale: Plain assignments keep the shell-variable semantics of the old sourced .env without widening what reaches the CLI's environment.)

Next steps:

  • /fs-review — request a re-review of the changes
  • /fs-fix <your instruction> — run another fix pass with specific guidance
  • Push commits directly — review re-runs automatically on push
    Updated by fullsend fix agent

fullsend-ai-coder Bot added a commit that referenced this pull request Oct 19, 2026
The data loader printed export lines only for exported names, so a plain
NAME=value in .env never reached the launch shell. Later launch lines
that expand such a variable (for example RUST_LOG or the Vertex project
defaults) lost the value, unlike when .env was sourced. Emit a plain
NAME='value' assignment for non-exported names and keep export for
exported ones, so the export attribute is preserved. Add a regression
test and refresh the codex golden launch files.

Note: pre-commit could not fetch its hook repositories (TLS failure in
the sandbox); gofmt, go vet, git diff --check, the broken-symlink lint
and scan-secrets were run directly. Tests in internal/runtime pass except
TestBuildRunCommand_ClaudeMissingExits127, which also fails without this
change (a claude binary is present on the sandbox PATH).

Addresses #8565

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🤖 Review · ❌ Terminated · Started 3:09 PM UTC · Ended 3:19 PM UTC

Commit: b6e7170 · View workflow run →

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 6:54 PM UTC · Completed 7:04 PM UTC

Commit: 60e3118 · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.96

fullsend-ai-review[bot]

This comment was marked as outdated.

fullsend-ai-coder Bot and others added 7 commits October 19, 2026 16:05
The Claude Code, codex and pi launches sourced /sandbox/workspace/.env
as shell in the same process that then ran the launch-time checks and
started the CLI. Code in .env therefore ran before those checks
finished: it could rewrite a hook file and exec the CLI itself, so the
later unsets, the second integrity pass and the pinned binary never
ran.

envDataLoad (internal/runtime/env_data.go) replaces `. .env` in all
three launches. A python3 pinned before anything the agent wrote, run
with -I -S, parses .env and prints single-quoted export lines that the
launch evals. It accepts only `[export ]NAME=value` (quoted values,
$NAME/${NAME}, a leading ~), `export NAME` and comments, plus the four
control lines the runner writes (PATH capture/restore, the .env.d loop,
iteration.env), which it interprets as data. Any other line is ignored
and reported by file and line number, never by content. LD_PRELOAD,
LD_LIBRARY_PATH, LD_AUDIT, IFS and each launch's read-only pins are
never taken from .env, for every runtime, which also closes #7580 for
pi. The agent's own .env writes, such as a PATH prepend, keep working.

The post-.env unsets and second guard passes stay as a second layer.
`[` is added to the Claude post-.env `unset -f` list, matching pi.
A cli test keeps the runner's .env control lines and the loader's in
step. OpenCode is not named in the issue and still sources .env.

Tests: new env_data_test.go runs the loader under /bin/sh against a
hostile .env (command substitution, functions, exec, LD_* and a
readonly-pin write); launch tests that relied on .env executing now
assert it does not; codex golden files regenerated.

Note: pre-commit could not fetch its remote hook repos (TLS error in
the sandbox). gofmt, go vet, lint-docs-links, lychee, whitespace
checks and scan-secrets were run directly and pass. ruff, bandit,
shellcheck and actionlint do not apply to the changed files.
TestBuildRunCommand_ClaudeMissingExits127 fails in this sandbox on
main too, because /usr/bin/claude exists here.

BREAKING CHANGE: on Claude Code, codex and pi runs, .env and
.env.d/*.env lines other than NAME=value assignments, `export NAME`
and comments no longer run at launch; they are ignored with a warning.
Rewrite such .env.d host files as plain `export NAME=value` lines.

Closes #8498
Closes #7580

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fail the launch when .env.d files or iteration.env exist but cannot be
read, drop PYTHONPATH/PYTHONHOME/PYTHONSTARTUP/PYTHONUSERBASE from .env,
and escape file paths in loader messages. Update stale docs (cli-internals,
run, claude, codex, pi), add an ADR 0100 implementation note, and tidy the
runner-path constant and a test index.

Disagreement: OpenCode still sources .env; moving it to the data loader is
left to a maintainer-approved follow-up.

Note: pre-commit could not fetch its hook repos (TLS error in the sandbox);
gofmt, go vet, lint-docs-links, git diff --check and scan-secrets passed.
TestBuildRunCommand_ClaudeMissingExits127 and some internal/cli tests fail
in this sandbox independent of this change.

Addresses #8565

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The data loader printed export lines only for exported names, so a plain
NAME=value in .env never reached the launch shell. Later launch lines
that expand such a variable (for example RUST_LOG or the Vertex project
defaults) lost the value, unlike when .env was sourced. Emit a plain
NAME='value' assignment for non-exported names and keep export for
exported ones, so the export attribute is preserved. Add a regression
test and refresh the codex golden launch files.

Note: pre-commit could not fetch its hook repositories (TLS failure in
the sandbox); gofmt, go vet, git diff --check, the broken-symlink lint
and scan-secrets were run directly. Tests in internal/runtime pass except
TestBuildRunCommand_ClaudeMissingExits127, which also fails without this
change (a claude binary is present on the sandbox PATH).

Addresses #8565

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
An exported BASH_ENV from the agent-writable .env ran a file in every
non-interactive bash the CLI started; ENV does the same for an
interactive sh. Add both to envDataDropNames for every runtime, with a
test that a bash child does not run a planted BASH_ENV file, and list
the full drop set in the runtime and harness docs.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
…th python3 -E

Dropping four Python startup names left the rest of the namespace open:
PYTHONWARNINGS can name a warning category in a module, so CPython imports
it while initialising warnings, and importing antigravity runs the BROWSER
command. pi's hook adapter starts python3 with the full environment, so the
payload ran before each hook script's checks.

The loader now drops any name with a PYTHON prefix (a trailing * in
envDataDropNames), and fullsend-hooks.js starts the hook interpreter with -E.
Tests cover PYTHONWARNINGS, PYTHONINSPECT via a separate export line and a
non-matching NOTPYTHONX name, and assert the -E argument.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
-E alone left the user site directory on. pi does not restore HOME after
the .env load, so an earlier iteration could plant a usercustomize.py under
an agent-chosen HOME that ran before the hook script and exited 0, which
runScript reads as an allowed call. Start the hook interpreter with the
same -E -s -B flags as the Claude hook launcher.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
…ces .env

Open env files with newline="" so a CR or CRLF inside a value comes out
as sourcing would keep it, with a round-trip test. Note in the OpenCode
runtime page that OpenCode still sources .env as shell (#8574).

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 8:10 PM UTC · Completed 8:24 PM UTC

Commit: 7ab89dc · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $3.17

@fullsend-ai-review
fullsend-ai-review Bot dismissed stale reviews from themself October 19, 2026 20:24

Superseded by updated review

@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label Oct 19, 2026

@waynesun09 waynesun09 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving at 7ab89dc after the takeover: BASH_ENV/ENV and every PYTHON* name are dropped from .env, pi hooks run python3 -E -s -B, and .env values keep CR bytes. Each fix was reproduced before and checked by a mutation test. internal/runtime, internal/cli and the pi extension tests pass on Fedora (bash as sh) and Debian (dash); CI is green. Follow-ups: #8574, #8575, #8577.

@waynesun09
waynesun09 added this pull request to the merge queue Oct 19, 2026
Merged via the queue into main with commit 5fc4c47 Oct 19, 2026
52 checks passed
@waynesun09
waynesun09 deleted the agent/8498-env-as-data branch October 19, 2026 20:48
Benkapner pushed a commit to Benkapner/fullsend that referenced this pull request Oct 20, 2026
Follow-ups from the fullsend-ai#8565 reviews of the loader that reads the
agent-writable .env as data (internal/runtime/env_data.go).

Loader:
- A value containing a NUL byte is dropped with a warning naming
  the file and line, like every other dropped line, instead of
  silently at output time.
- An .env.d directory that exists but cannot be listed (or whose
  files cannot be stat'ed) now records the error and fails the
  launch, as an unreadable .env.d file already did; a missing
  directory is still read as empty.
- A rejected statement whose quotes span lines is skipped to where
  a shell would end it, so lines inside its value are no longer
  parsed as assignments. An unterminated quote still falls back to
  the line end.
- python3 is pinned with `command -p -v python3` first, falling
  back to `command -v python3`, so a python3 early on the launch
  PATH is not used when the default PATH has one (new
  binaryPinLookup helper).
- The loader script takes FULLSEND_RUNNER_PATH from
  envDataRunnerPathVar instead of spelling it out.

Tests: a planted re/ package in the working directory and on
PYTHONPATH is not imported; LD_*, BASH_ENV and ENV from .env.d,
iteration.env and a separate `export NAME` line are dropped; NUL
values; the built pi launch run end to end with a stub pi; the
control-lines test no longer depends on harnessEnvLines()[0]; the
Claude hooks launch test skips where /bin/sh rejects `unset -f [`
(bash 3.2 on macOS). Codex golden launch files regenerated.

Docs: claude.md says the image needs python3; codex.md, the ADR
0100 implementation note and the envDataLoad comment no longer say
only `export` lines are evaluated; the harness reference lists the
shell forms the loader drops (${NAME:-default}, export A=1 B=2,
FOO=x; export FOO); stale `. .env` comments in claude.go and
pi_run.go updated.

Not done here: limiting $NAME expansion and replacing the drop
denylist with an allowlist both change what existing .env.d files
get and need a maintainer design decision.

Note: pre-commit could not fetch its remote hook repos (TLS
failure in the sandbox); gofmt, go vet, the ADR lints, broken
symlinks, docs-links, lychee and whitespace checks were run
directly and pass. Unrelated tests that fail on main in this
sandbox too: TestBuildRunCommand_ClaudeMissingExits127 (a real
claude is in /usr/bin), TestStartFetchService_* and
TestPostScriptEnv_NoSchema* in internal/cli.

Related to fullsend-ai#8575

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active and 1 inactive deployments
site-preview — 7ab89dcb Deployed Oct 19, 2026 by github-actions[bot]
dev — 7ab89dcb Deployed Oct 19, 2026 by waynesun09 via playback #17197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/sandbox OpenShell sandbox environment fullsend-no-fix Skip bot-triggered fix agent runs go Pull requests that update go code ready-for-merge All reviewers approved — ready to merge ready-for-review Triggers review agent dispatch risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Launch must not execute the agent-writable .env as shell (all runtimes) pi launch does not clear LD_* loader variables after sourcing .env

1 participant