Repository navigation
fix(#8498)!: read the agent-writable .env as data at launch - #8565
Conversation
|
🤖 Review · Commit: |
|
🤖 Finished Review · ✅ Success · Started 2:04 PM UTC · Completed 2:22 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $4.35 |
Site previewPreview: https://59cb2cbc-site.fullsend-ai.workers.dev Commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
<!-- fullsend:risk-assessment --> DetailsHigh 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 --> DetailsHigh 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 --> DetailsHigh 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 --> DetailsHigh 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 --> DetailsHigh 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 --> DetailsHigh 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 --> DetailsHigh 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. |
|
Looks good to me Earlier findings
Previous run<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6Im1pc3NpbmctZG9jI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NjMyNWE0NzUzOWM4IiwibGluZSI6MTIwLCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJiYWNrd2FyZC1pbmNvbXBhdGlibGUiLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9lbnZfZGF0YS5nbyIsImlkIjoiZl9hNWNiYmM2YTVkMDc1ZTkxIiwiYWN0aW9uYWJsZSI6ZmFsc2V9XX0= --> ReviewFindingsMedium
Low
Next steps:
Previous run (4)ReviewFindingsLow
Earlier findings
Previous run (5)<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJtZWRpdW0iLCJjYXRlZ29yeSI6ImxvZ2ljLWVycm9yIiwiZmlsZSI6ImludGVybmFsL3J1bnRpbWUvZW52X2RhdGEuZ28iLCJpZCI6ImZfYTFjNGQ1MjEyZTUwZjQyNCIsImxpbmUiOjMwNiwiYWN0aW9uYWJsZSI6dHJ1ZX0seyJzZXZlcml0eSI6ImxvdyIsImNhdGVnb3J5IjoiYXJjaGl0ZWN0dXJhbC1jb25mbGljdCIsImZpbGUiOiJkb2NzL0FEUnMvMDEwMC1jb2RleC1zYW5kYm94LWhvb2tzLm1kIiwiaWQiOiJmX2M5ODkzN2YzYzVkM2RlYzYiLCJsaW5lIjo2NywiYWN0aW9uYWJsZSI6ZmFsc2V9LHsic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6ImJyZWFraW5nLWNsaSIsImZpbGUiOiJpbnRlcm5hbC9ydW50aW1lL2Vudl9kYXRhLmdvIiwiaWQiOiJmXzU5ZWIxMDQwM2Y2MDg1NzciLCJsaW5lIjoxMDAsImFjdGlvbmFibGUiOmZhbHNlfV19 --> ReviewFindingsMedium
Low
Next steps:
Previous run (6)ReviewFindingsMedium
Low
Labels: PR changes the sandbox runtime launch path (Go) and related docs Next steps:
|
|
🤖 Finished Fix · ✅ Success · Started 2:24 PM UTC · Completed 2:37 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.55 |
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>
🔧 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):
Disagreed (1):
Tests: passed CI inspections (3):
Conflict update: skipped; strategy Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 2:39 PM UTC · Completed 2:52 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $3.20 |
|
🤖 Finished Fix · ✅ Success · Started 2:54 PM UTC · Completed 3:06 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.40 |
🔧 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):
Disagreed (2):
Tests: passed CI inspections (5):
Conflict update: skipped; strategy Decision points
Next steps:
|
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>
|
🤖 Review · ❌ Terminated · Started 3:09 PM UTC · Ended 3:19 PM UTC Commit: |
|
🤖 Finished Review · ✅ Success · Started 6:54 PM UTC · Completed 7:04 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.96 |
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>
60e3118 to
7ab89dc
Compare
|
🤖 Finished Review · ✅ Success · Started 8:10 PM UTC · Completed 8:24 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $3.17 |
Superseded by updated review
waynesun09
left a comment
There was a problem hiding this comment.
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.
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>
Summary
The Claude Code, codex and pi launches no longer source the agent-writable
/sandbox/workspace/.envas shell. A pinned, isolatedpython3reads it, and the.env.dfiles anditeration.envit names, asNAME=valuedata. The launch shell thenevals only the loader's single-quotedexportlines. Before this change, code in.envran before the launch checks finished, so it could rewrite a hook andexecthe CLI itself.Related Issue
Also closes #7580: pi no longer receives
LD_PRELOAD,LD_LIBRARY_PATHorLD_AUDITfrom.env.Changes
internal/runtime/env_data.go(new):envDataLoadpinspython3the same way the CLIs are pinned (binaryPin) and runs it with-I -S.[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.dloop,iteration.env), which it interprets as data.exec,.,readonly,;-joined commands, other parameter expansions). A warning names the file and line number but never the content..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:. .envis replaced byenvDataLoad. The existing post-.envunsets and second guard passes are kept as a second layer.[is added to the post-.envunset -flist, matchingpi_run.go.internal/cli/run_test.go: newTestEnvDataControlLinesMatchRunnerkeeps the linesbootstrapEnvwrites in step with the lines the loader recognizes..env.dhost files), customizing-agents,docs/runtimes/claude.md, and a new security-matrix row inruntime-implementation.md.Breaking change
On Claude, codex and pi runs,
.env/.env.d/*.envlines other than assignments,export NAMEand comments no longer run at launch; they are ignored with a warning. The fleet's.env.dfiles are plainexport NAME=valuelines, which keep working, as do the agent's own.envwrites (for example a PATH prepend).Design notes / open points for review
.envas a code path.env -iwould drop those placeholders.python3in the sandbox image. The image already ships it for the hook scripts and codex. A custom image without it now fails the launch withpython3 not found on PATH(exit 127)..env. Triage flagged the same pattern there, so it is a follow-up candidate.Testing
internal/runtime/env_data_test.goruns the real loader under/bin/sh. Cases:.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;.envwith.env.dfiles anditeration.env;export NAMEsemantics, and a missing.env..envexecuting (hook rewrite between the guard passes, asha256sumfunction, gatewayreadonlyand placeholder overrides) now assert that the.envcode does not run and that the runner's values win.TestBuildPiRunCommand_LoaderEnvHygienenow covers LD_* for pi. The codex golden files are regenerated.go test ./internal/runtime/passes exceptTestBuildRunCommand_ClaudeMissingExits127, which also fails onmainin the agent sandbox because a real/usr/bin/claudeexists 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 andscan-secretswere run directly and pass.Checklist
!for the breaking change)🤖 Generated with Claude Code
Closes #8498
Post-script verification
agent/8498-env-as-data)af8cd4756172ec105c3aa523515c9c7d51684e90..HEAD)