Repository navigation
fix(#8574)!: read .env as data in the OpenCode launch and runner probes - #8590
Conversation
|
🤖 Finished Review · ✅ Success · Started 9:43 PM UTC · Completed 9:58 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $2.87 |
Site previewPreview: https://48288272-site.fullsend-ai.workers.dev Commit: |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
<!-- fullsend:risk-assessment --> DetailsModerate change size with no protected paths or dependency changes, balanced by elevated churn and multi-author contention in runtime packages alongside clean issue scope alignment for the unflagged launch behavior update. Previous run<!-- fullsend:risk-assessment --> DetailsModerate change size with no protected paths or dependency changes, balanced by elevated churn and multi-author contention in runtime packages alongside clean issue scope alignment for the unflagged launch behavior update. Previous run (2)<!-- fullsend:risk-assessment --> DetailsModerate change size with no protected paths or dependency changes, balanced by elevated churn and multi-author contention in runtime packages alongside clean issue scope alignment for the unflagged launch behavior update. |
ReviewFindingsLow
Earlier findings
Previous run<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJtZWRpdW0iLCJjYXRlZ29yeSI6ImluamVjdGlvbi12dWxuIiwiZmlsZSI6ImludGVybmFsL2NsaS9ydW4uZ28iLCJpZCI6ImZfZDNmODMyZDExNGVkNTQwOCIsImxpbmUiOjU3MTAsImFjdGlvbmFibGUiOmZhbHNlfSx7InNldmVyaXR5IjoibWVkaXVtIiwiY2F0ZWdvcnkiOiJpbmNvcnJlY3QtZG9jIiwiZmlsZSI6ImRvY3MvZ3VpZGVzL3VzZXIvY3VzdG9taXppbmctYWdlbnRzLm1kIiwiaWQiOiJmXzE5ODNhNTk1NzI4NWVmZDEiLCJsaW5lIjo0NDYsImFjdGlvbmFibGUiOnRydWV9LHsic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6InN0YWxlLWRvYyIsImZpbGUiOiJkb2NzL2NvbnRyaWJ1dGluZy9ydW50aW1lLWltcGxlbWVudGF0aW9uLm1kIiwiaWQiOiJmX2VmY2Q3NmZmNGVhMDIyNjMiLCJsaW5lIjoxNjMsImFjdGlvbmFibGUiOnRydWV9LHsic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6ImluY29tcGxldGUtZG9jIiwiZmlsZSI6ImRvY3MvcmVmZXJlbmNlL2hhcm5lc3MtcmVmZXJlbmNlLm1kIiwiaWQiOiJmXzBkZWVjNzRkNjU5MmIxMDEiLCJsaW5lIjoxODUsImFjdGlvbmFibGUiOnRydWV9LHsic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6ImJyZWFraW5nLWNvbmZpZyIsImZpbGUiOiJkb2NzL3J1bnRpbWVzL29wZW5jb2RlLm1kIiwiaWQiOiJmX2E5MjU5ZmIzNDgwMmU5NGEiLCJhY3Rpb25hYmxlIjpmYWxzZX1dLCJkaXNwb3NpdGlvbnMiOlt7ImlkIjoiZl9hOTI1OWZiMzQ4MDJlOTRhIiwic3RhdHVzIjoib3BlbiJ9XX0= --> ReviewFindingsMedium
Low
Next steps:
Previous run (2)<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJhcHByb3ZlIiwiZmluZGluZ3MiOlt7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJicmVha2luZy1jb25maWciLCJmaWxlIjoiZG9jcy9ydW50aW1lcy9vcGVuY29kZS5tZCIsImlkIjoiZl9hOTI1OWZiMzQ4MDJlOTRhIiwiYWN0aW9uYWJsZSI6ZmFsc2V9XX0= --> ReviewFindingsLow
Labels: PR changes Go runner and runtime env handling for agent launches and has security implications. |
envDataLoad, but the OpenCode launch still sourced the agent-writable /sandbox/workspace/.env, so a line there or in an .env.d file could run before the launch checks finished. The runner's in-sandbox probes also sourced it as shell. The OpenCode launch now reads .env through envDataLoad, dropping LD_*, PYTHON*, BASH_ENV, ENV, IFS and every OpenCode read-only pin (the binary, utility and trusted-env pins), so an assignment to one cannot abort the launch. The post-.env re-pin, trusted-env restore, override reset and agent-file guard stay as a second layer. The probes use the same loader, so they see what the launch sees and run no .env or .env.d line: the pre-agent context scan and the GitHub preflight (through a new exported runtime.EnvDataLoad), codex's harness hook-variable read and OpenCode's trusted-env read. The preflight discards the loader's warnings so they cannot reach its 401/404 classification. The codex read now skips a bad line, as the launch does, instead of failing; an unreadable .env still fails it. The harness reference, the security feature matrix row, the OpenCode runtime page and the customizing-agents guide are updated. BREAKING CHANGE: OpenCode launches and the runner's probes now take only `[export ]NAME=value`, `export NAME` and comment lines from .env and .env.d files; any other line is ignored with a warning. Rewrite host_files .env.d content that relied on shell constructs as plain assignments, as Claude Code, codex and pi already require. Closes #8574 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OpenCode launches now read .env with the pinned python3, so the image needs the same python3 and regular-file readlink the other runtimes do. Assisted-by: Claude Signed-off-by: Wayne Sun <gsun@redhat.com>
9fd166a to
b11c094
Compare
|
🤖 Finished Review · ✅ Success · Started 6:05 AM UTC · Completed 6:19 AM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $3.40 |
Superseded by updated review
🔧 Fix agent — iteration 1 (bot-triggered)Fixed the four documentation findings and corrected the overstated run.go comment. Deferred the advisory PATH-pinning code change for find and gh as maintainer follow-up. The changes are docs plus one comment. gofmt and go build pass. Pre-commit could not run because hook repos were unreachable, and the full test suite was not run. Fixed (5):
Disagreed (1):
Tests: passed CI inspections (5):
Conflict update: skipped; strategy
|
|
/fs-fix-stop |
|
Fix agent disabled for this PR. Remove the |
|
🤖 Review · Commit: |
The pre-agent context scan and the GitHub preflight read .env as data, but still ran a bare find and gh, looked up on the PATH .env left. Run both with the trusted PATH recorded before .env (EnvDataTrustedPathVar). Assisted-by: Claude Signed-off-by: Wayne Sun <gsun@redhat.com>
|
🤖 Finished Review · ✅ Success · Started 6:36 AM UTC · Completed 6:44 AM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.73 |
Superseded by updated review
Summary
Moves the OpenCode launch and the runner's in-sandbox probes onto
envDataLoad. That is the pinnedpython3 -I -Sloader #8565 added for Claude Code, codex and pi. With this change fullsend no longer sources the agent-writable/sandbox/workspace/.envor.env.d/*.envas shell anywhere it reads them.Security-sensitive launch-path change. Human review is advisable.
Related Issue
#8574 (follow-up to #8498 / #8565)
Changes
internal/runtime/opencode_run.go):. .envis replaced withenvDataLoad(envFile, openCodeEnvDataDrop...). It dropsLD_*,PYTHON*,BASH_ENV,ENV,IFSand all 12 OpenCode read-only pins: the binary, utility and trusted-env/HOME/PATH pins. An assignment to a pin is dropped, so it can't abort the launch. The post-.envEnvExportsre-pin, trusted-env restore, override reset and agent-file and adapter guards stay in place as a second layer. Comments that described.envas sourced are updated..envor.env.dline:buildScanContextCommand) and the GitHub preflight (checkSandboxGitHubConnectivity), through a new exportedruntime.EnvDataLoad. The preflight discards the loader's warnings. Otherwise a message like "line 401" would end up in the output thatdiagnosePreflightGitHubFailuresearches for401/404.codexReadHarnessSecurityEnvCmd) and OpenCode's trusted-env read (openCodeTrustedEnvReadCommand)..env.dhost files), the security feature matrix row (OpenCode is now ✓, and the probes are mentioned), the OpenCode runtime page (the "still sourced" caveat is removed) and the customizing-agents guide.Behaviour change (breaking)
OpenCode runs and the probes now take only
[export ]NAME=value,export NAMEand comment lines from.env/.env.d. Other lines are ignored with a warning that gives the file and line, never the content. Claude Code, codex and pi already behave this way. The codex harness-env read used to fail Bootstrap on a.envwith a syntax error or a failing last line. It now skips that line and reads the values around it, as the codex launch does. A missing or unreadable.envstill fails the read.The launch needs
python3and a regular-filereadlinkinPATHdirectories the sandbox user neither owns nor can write (as for the other runtimes since #8591), and the context scan'sfindand the GitHub preflight'sghare looked up only in those directories. Aghplaced under/sandbox/(for example throughhost_filesin/sandbox/workspace/bin) is no longer used by the preflight, which then reportsgh CLI not available in sandboxand skips. The fullsend sandbox image is unaffected:ghandfindlive in/usr/bin.Testing
New
TestOpenCodeLaunch_HostileEnvDoesNotExecute, the issue's proposed test. It writes a.envand an.env.dfile containing command substitution, backticks, a function redefiningopencode, a bare command,exec,LD_PRELOAD/LD_LIBRARY_PATH/LD_AUDITand assignments to the read-only pins, then runs the OpenCode prelude pieces against them. It checks that nothing runs,LD_*never reachesopencode, plain exports from both files still apply, PATH is restored to the pre-.envpin, the pinned binary starts, and warnings name the file and line but not the content.The OpenCode run-command tests assert the rendered command contains the loader and no
. <envFile>.TestOpenCodeBinaryPin,TestOpenCodeTrustedEnvRestoreandTestOpenCodeTrustedEnvReadCommandnow go through the loader. The read test adds a marker command and a pin assignment.TestCodexReadHarnessSecurityEnvCmd: the bad-line cases now expect the values to be read, a new case checks that shell constructs don't run, and the missing-file case still fails.New shape tests for the scan-context command, both preflight commands, and
EnvDataLoad. The scan command was also run in the sandbox image with a.envthat puts another directory first onPATH: the image'sfindand the scanner run.Rebased on main after fix(#8575)!: harden and tidy the .env-as-data launch loader #8591;
go test ./internal/runtime/... ./internal/security/... ./internal/cli/... ./internal/harness/...pass as a non-root user on Linux (/bin/sh= dash).go test ./internal/runtime/ ./internal/cli/pass except five tests that fail identically on unmodifiedmainin this sandbox, for environmental reasons:TestBuildRunCommand_ClaudeMissingExits127(a realclaudeis on PATH),TestStartFetchService_*(sandbox networking), andTestPostScriptEnv_NoSchema*(the sandbox exportsFULLSEND_OUTPUT_SCHEMA; they pass with it unset).Patch coverage: every changed function is at 100%, except
buildScanContextCommandat 89.5%; its uncovered line was already uncovered before this change.pre-commitcouldn't fetch hook repos in the sandbox (TLS error), so I ran the applicable hooks directly. gofmt,go vet ./..., the pre-commit-hooks checks (v6.0.0), lint-broken-symlinks, lint-docs-links and lychee all passed, and so did the gitleaks-basedscan-secrets.Tests added/updated for new or modified logic
make lint(pre-commit run) couldn't run in the sandbox; the hooks were run directly as described aboveChecklist
fix(#8574)!:, breaking-change marker plusBREAKING CHANGE:trailer)🤖 Generated with Claude Code
Closes #8574
Post-script verification
agent/8574-opencode-env-as-data)5fc4c47a1d40c2ab0a748e3bd2f7b9f8a697ca50..HEAD)