Skip to content

Enable Codex shell tools inside hardened Docker enclaves - #11190

Merged
lpcox merged 7 commits into
mainfrom
copilot/make-codex-tools-executable
Nov 6, 2026
Merged

lpcox merged 7 commits into
mainfrom
copilot/make-codex-tools-executable

Conversation

Copilot AI commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex 0.159.3’s default nested sandbox fails with bwrap: Failed to make / slave: Operation not permitted, preventing the diagnostic from running despite CLI exit 0.

  • Execution mode: Select Codex’s supported externally sandboxed mode:
    codex exec --dangerously-bypass-approvals-and-sandbox --ephemeral
  • Confinement: Preserve AWF’s non-root identity, zero capabilities, no-new-privileges, read-only root/seed, bounded noexec writable paths, and dedicated proxy-only network.
  • Regression coverage: Exercise the real pinned CLI and shell tool with synthetic Responses inference; require schema-valid diagnostic output and peer/public-egress denial. Verify failed commands and missing output remain canonical failures even when Codex exits 0.
  • Documentation: Explain the outer-sandbox contract and required /awf/out result channel.

Copilot AI changed the title [WIP] Fix execution of Codex shell tools in hardened Docker enclave Enable Codex shell tools inside hardened Docker enclaves Nov 6, 2026
Copilot AI requested a review from lpcox November 6, 2026 15:16
@lpcox
lpcox marked this pull request as ready for review November 6, 2026 15:22
Copilot AI adaptive review requested due to automatic review settings November 6, 2026 15:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Critical disclosure paths allow shell workloads to expose private seed data through exported audit transcripts and unrestricted hosted-web proxy requests, bypassing result-validation and disclosure-budget safeguards.

4 open issues
What changed in this PR

This PR addresses #11185 by letting Codex rely on AWF’s outer enclave sandbox instead of starting nested bubblewrap, enabling shell diagnostics without changing container confinement settings.

Changes:

  • Selects Codex’s externally sandboxed execution mode.
  • Adds pinned-CLI shell integration coverage and checks that empty output remains a failure despite CLI exit zero.
  • Documents the outer-sandbox contract and required /awf/out result channel.
File Description
tests/​integration/​enclave-codex-shell.test.ts Adds real Codex shell tests with synthetic inference, confinement checks, and failure scenarios.
src/​enclave/​agent-entrypoint-diagnostics.test.ts Checks sandbox flags and rejects shell-launch failures despite CLI exit zero.
docs/​enclaves-architecture.md Explains external sandboxing and the required result file.
containers/​enclave/​agent-entrypoint.py Enables Codex’s approval and nested-sandbox bypass flag.

Review effort: Max (auto)

Comment thread containers/enclave/agent-entrypoint.py Outdated
# AWF supplies the outer sandbox; nested bubblewrap cannot run with zero capabilities.
return [
CODEX_BIN, "exec", "--skip-git-repo-check",
"--dangerously-bypass-approvals-and-sandbox",
Comment thread containers/enclave/agent-entrypoint.py Outdated
# AWF supplies the outer sandbox; nested bubblewrap cannot run with zero capabilities.
return [
CODEX_BIN, "exec", "--skip-git-repo-check",
"--dangerously-bypass-approvals-and-sandbox",
Comment on lines +192 to +201
args[args.indexOf('--entrypoint') + 1] = '/usr/bin/python3';
args.push('/usr/local/bin/run-enclave-agent');
args.splice(1, 0, '-d',
'-v', `${path.join(root, 'containers/enclave/agent-entrypoint.py')}:/usr/local/bin/run-enclave-agent:ro`,
'-v', `${path.join(root, 'containers/enclave/public_debug_capture.py')}:/usr/local/bin/public_debug_capture.py:ro`);
docker(args);
containers.push(containerName);
const members = Object.values(JSON.parse(docker(['network', 'inspect', network]))[0].Containers)
.map((member: unknown) => (member as { Name: string }).Name).sort();
expect(members).toEqual([proxyName, containerName].sort());
@lpcox

lpcox commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main, resolve conflicts, and address all review feedback

Copilot AI commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge main, resolve conflicts, and address all review feedback

Merged main without conflicts in db3263f and addressed all four findings in 6228b13: workload-written transcripts remain private, dedicated hosted-web tools are disabled independently of primary policy, topology inspection uses a readiness/release handshake, and transcript assertions check escaped commands plus the proof marker. All 373 targeted tests passed, including real Codex 0.159.3 Docker scenarios; build/type-check, lint and secret scanning passed. CodeQL analysis was skipped because its database exceeded the size limit.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation has been built for this PR.

Download preview artifact

To view locally:

  1. Download the docs-preview-pr-11190 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit 34a0287

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 93.76% 93.76% ➡️ +0.00%
Statements 92.30% 92.31% 📈 +0.01%
Functions 93.08% 93.08% ➡️ +0.00%
Branches 86.58% 86.59% 📈 +0.01%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/services/enclave-mcp-service.ts 97.2% → 97.2% (+0.04%) 97.3% → 97.3% (+0.04%)
src/nvx/one-shot-process.ts 81.5% → 84.0% (+2.47%) 74.7% → 76.8% (+2.11%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

Smoke Codex

Outcome: reported_no_action

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.

Generated from Smoke Codex · gpt54 · ~13 AIC · ⊞ 21.0K · ◷

🔮 The oracle has spoken through Smoke Codex

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ Build Test Suite completed successfully!

Generated by Build Test Suite for #11190

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services is testing service connectivity for this pull request...

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Smoke Cloud Hypervisor completed. Cloud Hypervisor + Copilot passed.

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅

🛡️ Egress verdict from Smoke Copilot Network Isolation

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Security Guard: one item for reviewer attention

containers/enclave/agent-entrypoint.py (~L920): the Codex command now adds --dangerously-bypass-approvals-and-sandbox. Codex's own approval and sandbox layer is disabled, and model-driven shell commands run with only the AWF enclave container as the boundary.

This is a deliberate trade-off, since the added comment says nested bubblewrap cannot run with zero capabilities. It is only safe if the enclave keeps all of the following:

  • no capabilities;
  • the internal network with the exact-membership assertion;
  • no credentials in the agent environment;
  • a read-only root filesystem and non-root user.

Suggested action: confirm that enclave-agent-service tests assert those properties, so the flag cannot reach a less-hardened runtime. Also confirm that the flag is only passed for the codex engine inside the enclave.

containers/enclave/agent-executor/workspace.js: this change tightens security. Session transcripts are now always routed to raw-debug-sessions, because a workload can forge the sensitivity label. No concern.

No firewall, Squid, iptables, capability, or seccomp weakening was found.

Generated by Security Guard for #11190 · copilot · auto · ~13 AIC · ⊞ 8.2K · ◷
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

✅ Smoke Test: Copilot BYOK (Direct) Mode

Test Results:

Status: PASS — Direct BYOK mode (COPILOT_PROVIDER_API_KEY) operational

🔑 BYOK report filed by Smoke Copilot BYOK
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

chore: refresh canonical model sources
docs: sync schemas and specs with source changes
MCP connectivity: ✅
GitHub.com connectivity: ✅
File write/read test: ✅
BYOK inference test: ✅
Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra
Overall: PASS
cc @Copilot @lpcox

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia ✅ 1/1 passed ✅ PASS
Bun hono ✅ 1/1 passed ✅ PASS
C++ fmt ✅ N/A ✅ PASS
C++ json ✅ N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world ✅ N/A ✅ PASS
.NET json-parse ✅ N/A ✅ PASS
Go color ✅ ok ✅ PASS
Go env ✅ ok ✅ PASS
Go uuid ✅ ok ✅ PASS
Java gson ❌ 0 run ❌ FAIL
Java caffeine ❌ 0 run ❌ FAIL
Node.js clsx ✅ pass ✅ PASS
Node.js execa ✅ pass ✅ PASS
Node.js p-limit ✅ pass ✅ PASS
Rust fd ✅ 1/1 passed ✅ PASS
Rust zoxide ✅ 1/1 passed ✅ PASS

Overall: 7/8 ecosystems passed — FAIL

Java failure details: ~/.m2 is root-owned, so Maven couldn't create the local repo (Could not create local repository at /home/runner/.m2/repository). Retrying with -Dmaven.repo.local in a writable dir failed with Could not transfer artifact ... (internal_error) java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty. The JVM trust store is empty, so Maven can't reach Maven Central over HTTPS.

Note: .NET initially crashed on a missing /run/user/1001. It passed after setting XDG_RUNTIME_DIR.

Generated by Build Test Suite for #11190 · copilot · auto · ~26 AIC · ⊞ 5.7K · ◷
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Chroot Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.16 Python 3.12.16 ✅
Node.js v24.22.2 v22.23.2 ❌
Go go1.22.12 go1.22.12 ✅

Result: Not all tests passed (Node.js mismatch), so the smoke-chroot label was not added.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@lpcox
lpcox enabled auto-merge (squash) November 6, 2026 18:50
@lpcox

lpcox commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main and resolve the conflicts

auto-merge was automatically disabled November 6, 2026 19:17

Head branch was pushed to by a user without write access

Copilot AI commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge main and resolve the conflicts

Merged main and resolved all three conflicts in 803b6ef, preserving the review safeguards and main’s closed-metadata audit projection. Build, type-check, lint, secret scanning, and 713 targeted tests passed. Six environment-gated tests were skipped, including the four Docker Codex scenarios. CodeQL found no Python alerts; JavaScript analysis exceeded its database size limit.

Comment thread containers/enclave/agent-entrypoint.py Resolved
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@lpcox

lpcox commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Copilot AI commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix this failing ci check. make sure that 'npm test' runs without any failures https://github.com/github/gh-aw-firewall/actions/runs/42279934127/job/128105976734?pr=11190

Updated the Codex regression tests to require the bypass flag only with explicit opt-in. The targeted suite passed (102 tests), and full npm test passed (12,252 passed, 73 skipped). Commit: da29bd0.

@lpcox
lpcox merged commit 35b56fc into main Nov 6, 2026
46 of 48 checks passed
@lpcox
lpcox deleted the copilot/make-codex-tools-executable branch November 6, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make Codex shell tools executable inside the hardened Docker enclave

4 participants