Repository navigation
Exclude host runtime TMPDIR from AWF sandbox env - #79277
Conversation
install_awf_binary.sh exports TMPDIR=/tmp/gh-aw-runtime-* (host-private, 0700) via GITHUB_ENV. AWF --env-all forwarded it into the sandbox, whose /tmp is a private tmpfs, so the Copilot SDK driver failed with EACCES creating $TMPDIR/gh-aw/sandbox/agent/logs/copilot-session-state/<id>. - Exclude TMPDIR, GH_AW_RUNTIME_TMP_DIR and GH_AW_RUNTIME_TMP_ID from the agent and detection sandboxes. - Pin the Copilot session-state path to /tmp/gh-aw instead of os.tmpdir() in copilot_sdk_session.cjs and handle_agent_failure.cjs. Refs github/gh-aw-firewall#11824 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ PR Code Quality Reviewer completed the code quality review. PR Code Quality ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Specification Reviewer completed successfully! Caution agentic threat detected DetailsPotential security threats were detected in the agent output. Detected threat types: prompt injection. Review the workflow run logs for details. PR Specification ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Found one blocking compatibility issue: older AWF versions still inherit the host-private TMPDIR because --exclude-env is unavailable, so the targeted sandbox write failure can persist. See the inline comment for the required fallback or version enforcement.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| sortedExclude = append(sortedExclude, name) | ||
| } | ||
| } | ||
| slices.Sort(sortedExclude) |
There was a problem hiding this comment.
This still forwards the host-private TMPDIR to sandboxes whenever the configured AWF is older than the --exclude-env minimum, so the EACCES failure this change targets remains possible for supported older AWF versions.
💡 Why this matters
The new exclusions are only appended inside if awfSupportsExcludeEnv(...); the fallback logs and emits no exclusions while --env-all remains active. Either enforce the minimum AWF version for this path, fail compilation when these exclusions cannot be emitted, or provide an equivalent safe fallback for older images. Please add a regression test for the old-version branch.
There was a problem hiding this comment.
Added an old-AWF fallback that unsets the host temp variables before the sandboxed engine starts, with agent and detection coverage in a6a8c77.
Comment MemoryPeek at saved memory (review-history)History |
Comment MemoryPeek at saved memory (spec-review-history)History |
There was a problem hiding this comment.
🟡 Changes recommended
Session fixture paths diverge from the loader when TMPDIR differs from /tmp, and the exclusion test cannot detect removal of automatic TMPDIR exclusion.
2 open issues
What changed in this PR
This PR addresses Copilot SDK startup failures by keeping host-private temporary-directory settings out of AWF sandboxes and aligning session-state storage with the shared /tmp/gh-aw directory.
Changes:
- Exclude three host runtime variables from agent and detection sandboxes, with Go regression coverage.
- Pin Copilot session-state writing and failure analysis to the shared directory.
- Regenerate workflow lock files with the new environment exclusions.
| File | Description |
|---|---|
pkg/workflow/awf_env_test.go |
Tests sandbox exclusions and deduplication. |
pkg/workflow/awf_command_builder.go |
Adds host runtime environment exclusions. |
actions/setup/js/handle_agent_failure.cjs |
Reads session state from the shared path. |
actions/setup/js/copilot_sdk_session.cjs |
Defaults session writes to the shared path. |
.github/workflows/workflow-normalizer.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/update-astro.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/spec-enforcer.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/smoke-work-queue-worker.lock.yml |
Adds agent exclusions. |
.github/workflows/smoke-work-queue-dispatcher.lock.yml |
Adds agent exclusions. |
.github/workflows/smoke-github-codex.lock.yml |
Adds agent exclusions. |
.github/workflows/smoke-gemini.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/smoke-codex-bare-auto.lock.yml |
Adds agent exclusions. |
.github/workflows/smoke-codex-auto.lock.yml |
Adds agent exclusions. |
.github/workflows/smoke-claude-sub-agents.lock.yml |
Adds agent exclusions. |
.github/workflows/smoke-claude-copilot.lock.yml |
Adds agent exclusions. |
.github/workflows/smoke-claude-copilot-auto.lock.yml |
Adds agent exclusions. |
.github/workflows/smoke-claude-auto.lock.yml |
Adds agent exclusions. |
.github/workflows/smoke-azure-codex.lock.yml |
Adds agent exclusions. |
.github/workflows/smoke-agy.lock.yml |
Adds agent exclusions. |
.github/workflows/security-review.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/release.lock.yml |
Adds agent exclusions. |
.github/workflows/purelock.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/pdf-summary.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/notion-issue-summary.lock.yml |
Adds agent exclusions. |
.github/workflows/lint-monster.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/issue-arborist.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/gpclean.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/functional-pragmatist.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/firewall.lock.yml |
Adds SDK agent exclusions. |
.github/workflows/feature-grower.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/example-permissions-warning.lock.yml |
Adds agent exclusions. |
.github/workflows/eslint-monster.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/engine-conformance-pydantic-ai.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-opencode.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-mini-swe-agent.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-kiro.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-goose.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-gemini.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-factory.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-deepseek-harness.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-cursor.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-crush.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-copilot.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-codex.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-claude.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-aider.lock.yml |
Adds agent exclusions. |
.github/workflows/engine-conformance-agy.lock.yml |
Adds agent exclusions. |
.github/workflows/daily-token-consumption-report.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/daily-team-evolution-insights.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/daily-semgrep-scan.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/daily-max-ai-credits-test.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/daily-malicious-code-scan.lock.yml |
Adds SDK agent exclusions. |
.github/workflows/daily-harness-experiment-proposer.lock.yml |
Adds agent exclusions. |
.github/workflows/daily-go-test-stubs-aider.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/daily-doc-updater.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/daily-code-debt-aider.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/daily-cache-strategy-analyzer.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/daily-architecture-diagram.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/codex-github-remote-mcp-test.lock.yml |
Adds agent exclusions. |
.github/workflows/cloclo.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/changeset.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/bot-detection.lock.yml |
Adds agent exclusions. |
.github/workflows/artifacts-summary.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/agy-conformance-reusable.lock.yml |
Adds agent exclusions. |
.github/workflows/agentic-token-trend-audit.lock.yml |
Adds agent and detection exclusions. |
.github/workflows/agentic-token-optimizer.lock.yml |
Adds agent exclusions. |
.github/workflows/ace-editor.lock.yml |
Adds agent exclusions. |
.github/workflows/ab-testing-advisor.lock.yml |
Adds agent and detection exclusions. |
Review effort: Balanced (adaptive)
| @@ -93,7 +92,7 @@ const FAILURE_ISSUE_WINDOW_MS = FAILURE_ISSUE_DEDUP_WINDOW_HOURS * 60 * 60 * 100 | |||
| const DEFAULT_OTEL_JSONL_PATH = "/tmp/gh-aw/otel.jsonl"; | |||
| /** Path to the failure categories file written by handle_agent_failure and read by the OTLP conclusion span. */ | |||
| const FAILURE_CATEGORIES_PATH = "/tmp/gh-aw/failure_categories.json"; | |||
| const COPILOT_SESSION_STATE_DIR = path.join(os.tmpdir(), "gh-aw", "sandbox", "agent", "logs", "copilot-session-state"); | |||
| const COPILOT_SESSION_STATE_DIR = "/tmp/gh-aw/sandbox/agent/logs/copilot-session-state"; | |||
There was a problem hiding this comment.
Fixtures now use an isolated injected session directory; the production default remains shared. Fixed in a6a8c77.
| excluded := ComputeAWFExcludeEnvVarNames(phase.data, []string{"COPILOT_GITHUB_TOKEN", "TMPDIR"}) | ||
| joined := strings.Join(BuildAWFArgs(AWFCommandConfig{WorkflowData: phase.data, ExcludeEnvVarNames: excluded}), " ") | ||
| for _, name := range []string{"TMPDIR", "GH_AW_RUNTIME_TMP_DIR", "GH_AW_RUNTIME_TMP_ID"} { | ||
| assert.Equal(t, 1, strings.Count(joined, "--exclude-env "+name+" "), name) | ||
| } |
There was a problem hiding this comment.
Added cases with and without caller-provided TMPDIR, covering automatic exclusion and deduplication in a6a8c77.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /tdd, /diagnosing-bugs, and /codebase-design. Requesting changes: the golden snapshots are stale, and the JS test fixtures do not match the new session-state path.
📋 Key Themes & Verification
Blocking
- Stale golden snapshots:
TestWasmGolden_AllEnginesandTestWasmGolden_CompileFixturesfail because the goldens lack the newTMPDIR,GH_AW_RUNTIME_TMP_DIR, andGH_AW_RUNTIME_TMP_IDexcludes. - JS fixtures vs. code path:
handle_agent_failure.test.cjsbuilds session fixtures underos.tmpdir(), but the code now reads/tmp/gh-aw.
Non-blocking
- AWF version gate: on AWF older than
v0.25.3the fix is silently off. The PR description should state the minimum version. - Test input: the new Go test passes
TMPDIRas input, so the auto-add path is not proven by it. - Path literal:
/tmp/gh-awduplicatesTMP_GH_AW_PATHinconstants.cjs.
Verification
- ✅
TestHostRuntimeTmpEnvExcludedFromAWFSandboxespasses;gofmtis clean. - ✅ Lock files at HEAD carry the new flags.
⚠️ JS tests not run: sandbox TLS blockednpm ci.⚠️ TestBuildDynamicEnclaveExpiryScriptResolvesMinOfConfiguredAndJobExpiryappears clock-dependent and is unrelated to this change.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~12 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
| sortedExclude = append(sortedExclude, name) | ||
| } | ||
| } | ||
| slices.Sort(sortedExclude) |
There was a problem hiding this comment.
[/tdd] TestWasmGolden_AllEngines and TestWasmGolden_CompileFixtures now fail. The snapshots under pkg/workflow/testdata/ (for example TestWasmGolden_AllEngines/copilot.golden and TestWasmGolden_CompileFixtures/smoke-copilot.golden) do not include the three new --exclude-env flags, so they are stale.
💡 Suggested fix
Regenerate the goldens with the -update flag described in wasm_golden_test.go, then review the diff. It should add exactly the TMPDIR, GH_AW_RUNTIME_TMP_DIR, and GH_AW_RUNTIME_TMP_ID excludes and nothing else.
@copilot please address this.
There was a problem hiding this comment.
Regenerated and verified the WASM goldens in a6a8c77; their only changes add the three exclusions.
| @@ -93,7 +92,7 @@ const FAILURE_ISSUE_WINDOW_MS = FAILURE_ISSUE_DEDUP_WINDOW_HOURS * 60 * 60 * 100 | |||
| const DEFAULT_OTEL_JSONL_PATH = "/tmp/gh-aw/otel.jsonl"; | |||
| /** Path to the failure categories file written by handle_agent_failure and read by the OTLP conclusion span. */ | |||
| const FAILURE_CATEGORIES_PATH = "/tmp/gh-aw/failure_categories.json"; | |||
| const COPILOT_SESSION_STATE_DIR = path.join(os.tmpdir(), "gh-aw", "sandbox", "agent", "logs", "copilot-session-state"); | |||
| const COPILOT_SESSION_STATE_DIR = "/tmp/gh-aw/sandbox/agent/logs/copilot-session-state"; | |||
There was a problem hiding this comment.
[/tdd] COPILOT_SESSION_STATE_DIR is now pinned to /tmp/gh-aw, but handle_agent_failure.test.cjs still builds its session fixtures under os.tmpdir() (lines 7083, 7096, 7113, 7167, 7200, 7231, 7250). Those fixtures only match the code when os.tmpdir() resolves to /tmp, so they break as soon as TMPDIR is set to anything else.
💡 Suggested fix
Switch those fixtures to the same /tmp/gh-aw/sandbox/agent/logs/copilot-session-state path, or reuse TMP_GH_AW_PATH from constants.cjs. Also add one test that sets TMPDIR to a non-/tmp directory and checks that session state is still found. That locks in the fix.
@copilot please address this.
There was a problem hiding this comment.
Isolated the fixtures and added a non-default TMPDIR regression in a6a8c77. Vitest could not run because the configured npm feed failed DNS resolution.
|
Warning Threat detection engine error Threat detection could not complete its analysis due to a tooling error. This is not a security finding. What happenedThe threat detection engine failed to produce results. Review the workflow run logs to troubleshoot the error. 🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data
|
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Addressed the review feedback and refreshed WASM goldens in a6a8c77. Focused Go/WASM tests passed. Merge-main was blocked by a missing object on the Git remote; Vitest and the final gate were blocked by npm feed DNS failure. The separate connector test passed on rerun. No CI was triggered. |
| const defaultSessionStateBase = path.join(os.tmpdir(), "gh-aw", "sandbox", "agent", "logs", "copilot-session-state"); | ||
| // Pinned to /tmp/gh-aw (the shared host handoff dir), never os.tmpdir(): TMPDIR may | ||
| // point at a host-private runtime dir that is not shared with or writable in the sandbox. | ||
| const defaultSessionStateBase = path.join(TMP_GH_AW_PATH, "sandbox", "agent", "logs", "copilot-session-state"); |
|
@copilot review other agentic engines using os.tmpDir() |

Agent jobs using the Copilot SDK driver fail before the first model turn. The driver hits
EACCEScreating$TMPDIR/gh-aw/sandbox/agent/logs/copilot-session-state/<id>. The harness retries 4 times and the job fails. Example: https://github.com/github/gh-aw/actions/runs/44527777305/job/135573454637?pr=79268Why
install_awf_binary.shexports a host-privateTMPDIR=/tmp/gh-aw-runtime-*(mode 0700) viaGITHUB_ENV. AWF's--env-allforwards it into the sandbox. The sandbox's/tmpis a private tmpfs that shares only/tmp/gh-aw, so the forwarded path is not usable there. AWF also places its own workDir under that path and hides it with a tmpfs mount, which likely leaves a root-owned parent directory. Even if the path were writable, session state written there would not reach the host-side readers, which expect/tmp/gh-aw/....Changes
--exclude-envforTMPDIR,GH_AW_RUNTIME_TMP_DIR, andGH_AW_RUNTIME_TMP_IDinappendEnvAndMountArgs. This covers both the agent and detection sandboxes. The agent falls back to its own/tmp. Host-side steps keep the private runtime dir./tmp/gh-aw/...instead ofos.tmpdir()incopilot_sdk_session.cjsandhandle_agent_failure.cjs, to match the other readers (parse_token_usage.cjs,unified_session.cjs).--exclude-envflags.Notes for reviewers
make agent-report-progressstill fails on the custom Go linters. Those findings exist onmaintoo (for example,BuildAWFCommandis already over the line limit). This PR only touches thesort.Stringscall in the edited block, which now usesslices.Sort.path.join(os.tmpdir(), "gh-aw")call sites (subagent discovery in the Copilot harness,engine_subagent_models.cjs) behave correctly onceTMPDIRis excluded from the sandbox. They are left unchanged.Firewall-side follow-up: github/gh-aw-firewall#11824