Skip to content

Keep check environment values out of launcher arguments - #1355

Closed
eowca wants to merge 6 commits into
mainfrom
lean178/1029-private-check-environment
Closed

eowca wants to merge 6 commits into
mainfrom
lean178/1029-private-check-environment

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Keep check environment values out of launcher arguments

Context and goal

  • Goal: Checks receive their configured environment and private HOME without exposing variables as launcher arguments.
  • Problem: Forwarded values passed to Bubblewrap as arguments can appear in process listings.
  • Context: The namespace probe, Git alternate probe, and check launcher share the same Bubblewrap setup.

Closes #1029

Acceptance

  • Forwarded synthetic values reach the check without appearing in process arguments or launch diagnostics.
  • Unlisted variables stay absent and HOME stays private.
  • Both probes use the same environment channel.

Notes

Pass the filtered environment through Bubblewrap's file-descriptor option stream. Keep environment clearing inside Bubblewrap so config variables cannot affect the host launcher. Use a private file per launch to avoid shared offsets across probes and checks.

Local validation

Head b9abb58 passed all 75 sandbox tests, including the namespace and alternate probes.

Base

Base: a4fa169

Delivery boundary

Head e833fd1 passed all 83 sandbox tests. The branch preserves main's pipeline exit behavior. It is ready for a fresh base merge and gate after #1027 lands.

Validation

Recorded for 5120c98819ae

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

  • primary, claude, 4ee5654, approve

eowca and others added 5 commits November 26, 2026 01:09
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; Check diagnostics and launcher use the same environment precedence.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; The sandbox uses the same environment precedence and private option stream.
Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

loopzero primary review by claude on 4ee56540c87951e2a08b57746ddb625724c403ab, 63.7s: approve (0 critical, 0 important, 3 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/sandbox.py
options.seek(0)
fd = options.fileno()
return _proc.run(
[*prefix[:-1], "--args", str(fd), "--", *command],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: _run_bwrap silently relies on the prefix ending in "--"

[*prefix[:-1], "--args", ...] assumes the last element of prefix is the -- separator that bwrap_argv appends. If a caller passes a prefix built some other way, or bwrap_argv later adds anything after --, this would drop a real argument without any error. A check-mode prefix is also unusable without _run_bwrap: it has --clearenv but no --setenv, so a direct [*prefix, cmd] launch would run with an empty environment and no PATH. Smallest fix: assert prefix[-1] == "--", or have bwrap_argv return the options without the trailing -- and let _run_bwrap add it.

Comment thread src/loopzero/sandbox.py
probe = _proc.run(
[*prefix, "true"], cwd=worktree, env_allowlist=config.env_allowlist, timeout=GIT_TIMEOUT
)
probe = _run_bwrap(config, worktree, prefix, ("true",), timeout=GIT_TIMEOUT)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Reviewer namespace probe now differs from the real reviewer launch

runners._sandbox_prefix calls sandbox.probe with a reviewer prefix built with clearenv=False, which already carries --setenv arguments. Because probe now goes through _run_bwrap, the reviewer probe also gets an --args stream built from check_environment(review_config), which adds check defaults such as UV_CACHE_DIR. Its host launcher also gets only PATH, while the real reviewer launch gets BASE_ENV. Running true makes this harmless today, but it undercuts the docstring's claim that the probe tests 'the exact sandbox we will use', and reviewers now set environment through two channels. Consider giving probe a flag, or letting the reviewer path call _proc.run directly as before.

Comment thread src/loopzero/sandbox.py
# Apply settings inside bwrap without exposing the option stream in argv.
with tempfile.TemporaryFile() as options:
for name, value in check_environment(config).items():
if "\0" in value:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Null-byte check covers values but not names

_run_bwrap rejects values that contain NUL but writes names without checking them. A config.env key containing \0, or =, would shift the NUL-separated option stream and corrupt the options bwrap parses. Before this change, subprocess rejected such names when building argv. Validate name the same way as value.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Parked at approved head 4ee56540. GitHub checks counted 13,502 test lines against the 13,500 cap. The integration with current main projects 13,531. The local heavy-slot gate is pending PR #1352 landing on main, which raises the cap. No further source changes are needed for this blocker.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1427. Main added newline-preserving subprocess output, which conflicts with the reviewed descriptor plumbing in _proc.py. The replacement preserves both behaviors. Its process and sandbox suites passed, and the full exact-head gate is underway.

@eowca eowca closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: Keep forwarded check environment values out of process arguments

1 participant