Repository navigation
fix(config): let a process env set runtime option variables - #306
Merged
zastrowm merged 2 commits intoNov 5, 2026
Merged
Conversation
A `ProcessSpec` `env` refuses `NODE_OPTIONS`, `BASH_ENV`, `ENV`, `RUBYOPT`, `PERL5LIB`, `PERL5OPT`, `GEM_PATH`, `CLASSPATH`, `JAVA_TOOL_OPTIONS`, `_JAVA_OPTIONS`, and every `PYTHON*` name, with the error "is set by the box itself". The box sets none of these names. The refusal comes from `reserved_workload_environment`, which keeps a credential phantom out of a variable that makes a runtime load code. For an operator's literal in `env`, it protects nothing: the environment is composed, each process composes only its own `env`, and `command` can already state the same flags (`node --require x.cjs`). An operator who wants a runtime option must rewrite `command`, and the refusal also catches harmless names such as `PYTHONUNBUFFERED`. - `env.rs`: split the predicate into `box_owned_environment` (proxy routing, CA trust, `PWD`, `USER`, the OTLP exporter) and `loader_hook`. `reserved_workload_environment` is `loader_hook || box_owned_environment`, so it returns the same answer for every name, and a credential phantom is refused as before. - `env.rs` `refused_name`: a `ProcessSpec` `env` refuses `box_owned_environment` names as `SetByBox`, with the old message. It refuses `LD_*` and `DYLD_*` as `LoadsCode`, with a message that names the dynamic loader, because Box's own aliases run in the box and their loader would read the value. It accepts every other runtime option variable. - Library: `check_workload_env` uses `refused_name`, so it agrees with a `box.toml` load. `EnvRefusal::LoadsCode` now names only `LD_*` and `DYLD_*`, and its doc and `docs/design/containment.md` say so. - Interface: `box.toml` accepts `env` names that it refused before. No configuration that loads today stops loading. `docs/user/config.md` and `crates/box/AGENTS.md` state the new rule. - Test-workload comments no longer say that `NODE_OPTIONS` and `PYTHONPATH` are refused. The scripts do not change. - `process.rs::env_accepts_a_runtime_option_variable`: 12 names load in `[agent]`, `[tool.x]`, and `[mcp.x]`. It fails before the change. - `process.rs::env_refuses_a_dynamic_loader_variable_and_says_why`: `LD_PRELOAD`, `LD_LIBRARY_PATH`, and `DYLD_INSERT_LIBRARIES` are refused with the dynamic-loader message. It fails before the change. - `config::tests::an_interpreter_hook_cannot_receive_a_phantom`: unchanged, and it still refuses all 16 names as a phantom. - `library_env_check.rs::a_name_the_dynamic_loader_reads_is_refused_as_loading_code` and `a_runtime_option_variable_passes`: `check_workload_env` refuses 5 dynamic-loader names as `LoadsCode` and accepts 14 runtime option names. - `library_env_check.rs::the_check_and_a_box_load_refuse_the_same_entries_with_the_same_reason`: a full `box.toml` load accepts the 14 runtime option names in `[agent]` and in a stdio `[mcp.<name>]`. It fails before the change. - `box_programs.rs::an_agent_runtime_option_reaches_the_agent_and_no_tool` and `runtime_mcp_start.rs::an_agent_runtime_option_does_not_reach_an_mcp_server`: an `[agent] env` `NODE_OPTIONS` reaches the agent, and no tool or stdio MCP server receives it. - Run on macOS (arm64): `cargo fmt --all --check`, `just clippy`, and `cargo test --workspace --all-features --no-fail-fast` with `TMPDIR=/private/var/tmp/boxtmp`. Fixtures in `profile_conformance`, `contains_exec_target`, and `run::contain::boundary` refuse a temporary directory under the operator home or `/private/tmp`, so a run with another `TMPDIR` fails there on `main` too. - Linux: not run here. CI ran the Linux (arm64) unit tests.
This comment has been minimized.
This comment has been minimized.
|
Assessment: Approve Re-review at Checked and held at this head
The new sentence also stops an operator from expecting |
zastrowm
enabled auto-merge (squash)
November 5, 2026 18:24
kevin-orellana
approved these changes
Nov 5, 2026
kevin-orellana
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed configuration validation, environment composition, process isolation, and compatibility at 1fe81aa. I found no actionable defects. I verified nine relevant tests passed in both Linux and macOS CI logs. Independent testing could not complete because the development desktop ran out of disk space.
This was referenced Nov 5, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A process's own
envcan now set a runtime's option variables, such asNODE_OPTIONS,BASH_ENV,RUBYOPT,JAVA_TOOL_OPTIONS, andPYTHONPATH. Before this change,box.tomlrefused them with "envname ... is set by the box itself", but the box sets none of them.reserved_workload_environmentkeeps a credential phantom out of a variable that makes a runtime load code. AProcessSpecreused the same predicate. For an operator's literal value, the refusal protects nothing: the environment is composed, each process composes only its ownenv, andcommandcan already state the same flags.reserved_workload_environmentreturns the same answer for every name. AProcessSpecenvstill refuses the names Box sets itself, with the same message. It also refusesLD_*andDYLD_*, now with a message that names the dynamic loader, because Box's own aliases run in the box and their loader would read the value.check_workload_envagrees with abox.tomlload, so it now accepts these names too.EnvRefusal::LoadsCodenames onlyLD_*andDYLD_*.reserved_workload_environment's role, whichAGENTS.mdlists as frozen. The owner approved it. No configuration that loads today stops loading.docs/user/config.mdandcrates/box/AGENTS.mdstate the new rule.Design notes
reserved_workload_environmentkeeps its meaning. It stays the set that a credential may not claim, and it is now built fromloader_hookandbox_owned_environment. The phantom path needs no change, and its existing test still pins all 16 names.LD_*andDYLD_*stay refused inenv. Accepting them would give one rule with no exception. They are kept refused because they are the one case where Box's own code would load what it did not choose, even though the aliases are contained, so it is not an escape.NODE_OPTIONSandPYTHONPATHare refused, and that is no longer true. The comments change. The scripts keep--jitlessincommandandSTRANDS_LIB_DIR, because both still work and a change there is not part of this fix.Related Issues
None.
Type of Change
New feature
Testing
env_accepts_a_runtime_option_variableandenv_refuses_a_dynamic_loader_variable_and_says_whyfail before the change and pass after it.the_check_and_a_box_load_refuse_the_same_entries_with_the_same_reasonloads a fullbox.tomland accepts 14 runtime option names in[agent]and in a stdio[mcp.<name>]. It fails before the change.an_agent_runtime_option_reaches_the_agent_and_no_toolandan_agent_runtime_option_does_not_reach_an_mcp_serverstart a real box: the agent sees itsNODE_OPTIONS, and no tool or stdio MCP server receives it.macOS (arm64):
cargo fmt --all --check,just clippy, andcargo test --workspace --all-features --no-fail-fastwithTMPDIR=/private/var/tmp/boxtmp. Some containment fixtures refuse a temporary directory under the operator home or/private/tmp, onmaintoo.Linux (arm64): CI unit tests pass.
I ran the relevant suites (
just check, orcargo test --workspace --all-features)If I touched Rust, I ran
cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.