Repository navigation
feat(box): keep the vault of a secret source from each workload - #501
Conversation
## Problem
Box runs the program of a `[secret-source.<scheme>]` table outside every sandbox and delivers its secret as a placeholder. But a workload can still go around Box to the same vault. `reads`, `deny`, and `pass-secret-env` are stored and checked for shape only: a tool can take a grant over a path that the vault client reads, such as `~/.aws`, and a table can hold the vault's own credential in its `env`. The write-grant check of the last change covers the program file alone, so a write grant can cover a script that the program runs, as in `command = ["/bin/sh", "/Users/me/tools/vault.sh", "{ref}"]`. In each case the workload gets the secrets of the vault, or chooses what the next run starts with the operator's rights.
## Solution
Refuse each such configuration before a source program starts for the first time, in `run` and in `policy generate-schema`.
- `record::config::secret_source::ProtectedPath` is one `reads` or `deny` entry with its scheme. `Record::process_tables` and `read_secret_sources` put them in `ProcessTables`, and `boundary::judge_lists` gives them to `FilesystemContext`. So the early judgement and `ApprovedReach::judge_with` compare the same paths.
- `filesystem::direct_grants` refuses an authorizing entry that is at a protected path, inside it, or above it (`require_outside_source_paths`). The check runs before the floor of `containment`, so the refusal names the source and its entry also for a credential store, which has no exact-name exception beside a source that lists it. It compares the entry and the protected path as written and as they resolve, by spelling and by on-disk identity, so a link in either one does not hide the overlap, and an absent path is still protected. `ProtectedPath::spellings` resolves a protected path through each symbolic link (`layout::resolved_through_links`), also a link whose target is not there yet, because the sandbox checks the path that a name resolves to. A write grant over the folder that holds a link on the way is refused too, because a change to that link points the path elsewhere.
- `direct_grants` also gives each process a `Refusal` on each spelling of each protected path, with no pinned identity. The sandbox then denies the path under the cells that Box adds itself and under a tool's discovery of the home, and it stays denied when it appears after the box starts.
- `DeclaredSources::check` refuses a `reads` or `deny` entry with a `..` component, a second `/` after `~`, a control character, or a character that a filesystem list refuses (`*`, `?`, `[`, `]`, `{`, `}`). The compare and the denial need one place, `~//x` names `/x`, and the macOS profile cannot spell `{{` or a control character.
- `ConfiguredCommands` holds each spelling of each protected path and each link on the way, and `mutation_refusal` refuses a change through Strands Shell or Monty at one, inside it, or above it, and at a link or its folder. It compares by spelling, by on-disk identity, and by spelling with its letters folded, because an absent path has no identity and a volume that ignores case makes it under each case of its name. A read through an interpreter stays with policy.
- `ConfiguredCommands` holds each file that a later element of a source `command` names, when that element is the absolute path of an existing regular file (`ConfiguredCommand::named_file`). `validate_reach` and `mutation_refusal` cover it as they cover the program: the path, the file that it resolves to, each symbolic link on the way, and a folder that holds one of them. A file that Box cannot open is refused, and the refusal names it as a file of the `command`.
- `DeclaredSources::vault_credentials` reads the operator's variables that a `pass-secret-env` entry names, prefix entries included. `VaultCredential::refuse_held` refuses a process table whose `env` value or `command` element contains one of those values, under any name. The refusal names the variable and holds no value, and `VaultCredential` prints no value in its `Debug` form. A different value under the same name passes.
- `SecretSources::refuse_exposure` replaces `refuse_writable_programs`. It judges the lists and then the values of each process table, before the startup line and the first read.
Interfaces that moved:
- A grant that reaches a `reads` or `deny` path is refused, and so is a write grant over the folder of a link on the way to one, and a write grant over a file that a source `command` names, on `run` and on `policy generate-schema`.
- A process table whose `env` or `command` holds the operator's value of a `pass-secret-env` variable is refused.
- A `reads` or `deny` entry with `..`, a second `/` after `~`, a control character, or a pattern character is refused when the configuration loads, and so is a `command` element that names a file that Box cannot open.
- Strands Shell and Monty refuse a change at, inside, or above a `reads` or `deny` path, and a change to a symbolic link on the way to one or to the folder that holds that link.
- A `reads` or `deny` entry whose symbolic links do not end, or whose path Box cannot inspect, is refused before the first program starts.
- The sandbox of each process beside a source denies each `reads` and `deny` path.
- No key, record field, record version, startup line, or crate surface moves.
Not built: Strands Shell and Monty do not refuse a read of a `reads` or `deny` path, because no credential floor sits beneath the interpreters on `main` (#434 adds one). `docs/design/limitations.md` states this limit and the others.
## Tests
On this commit, on `main` `ab29afd3` (after #314 and #444). Since the rebase, the patch of this commit changed in docs only, in `crates/box/AGENTS.md`, `docs/user/config.md`, and `docs/design/limitations.md`, and in no code:
- Amazon Linux 2023 container (x86_64, Rust 1.98.1): `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` and `cargo fmt --all --check` are clean. `cargo test -p strands-box --all-features --locked --lib --no-fail-fast`: 1,154 passed and 16 failed, the same 16 as on the commit before this change. The doc guards `site_manifest`, `documented_inputs`, `four_inputs`, `documented_commands`, and `credential_method_scope`: 27, 2, 5, 1, and 2 passed. One test of the telemetry crate fails there, `export::tests::the_vault_attaches_a_credential_on_an_ipv6_address`: it fails in the same way on the commit before this change, because the container has no IPv6 loopback.
- macOS (arm64, Rust 1.96.0), the test targets of this change: `box_credentials` passed 36 tests and ignored 1, `mcp_schema_generation` passed 27, the unit tests of the changed modules passed 428, and `strands-box-credentials` passed 300 unit tests and 33 integration tests. `a_tool_cannot_see_and_the_shell_cannot_change_a_path_of_a_secret_source` passed in a real sandbox, with the Seatbelt change of #444 in the tree. This ran before the last change of this commit, which is in docs only.
Before the rebase onto `ab29afd3`, and not repeated on this commit:
- macOS: `cargo test --workspace --all-features --locked --no-fail-fast`: 3,572 passed, 1 failed, 15 ignored. Each box test of this change passed. The failure was an `egress-gateway` unit test (`a_pinned_address_the_authority_refused_is_never_dialed_whatever_its_position`), in a crate that this change does not touch, and it then passed 3 times alone on that revision and 3 times on `main`.
- macOS, six configurations in a real box with a stand-in vault program: the refusal of a tool grant on `~/.aws`, of a write grant over the folder of the program, of a write grant over the folder of a script that `command` names, and of a stdio MCP server whose `env` holds a `pass-secret-env` value, each before the program started; a box that starts, where neither the agent, a tool, nor the Shell reaches the vault's session file; and a box with no declaration, which starts as before.
- The container, the macOS-only tests that need no sandbox, with the operating-system check forced on: 371 unit tests and 12 tests through the built binary passed.
- 52 undo patches, one for each new check: each made its test fail. 49 ran in the container, and the 3 whose tests need a box ran on macOS.
Not run on this commit: the full macOS suite, and a real `op` or `aws`.
What each claim rests on:
- A grant at a protected path, inside it, or above it is refused in each list that authorizes: `a_grant_that_reaches_a_path_of_a_secret_source_is_refused`.
- A credential store beside a source that lists it has no exact-name exception: `a_credential_store_of_a_secret_source_is_refused_when_named_exactly`.
- An absent path and a link do not hide the overlap: `a_grant_that_reaches_an_absent_path_of_a_secret_source_is_refused`, `a_grant_that_reaches_a_path_of_a_secret_source_through_a_link_is_refused`.
- Each process is denied each protected path, and a box with no source gets no denial: `each_process_is_refused_each_path_of_a_secret_source`, `each_boundary_refuses_each_path_of_a_secret_source`, and `a_tool_cannot_see_and_the_shell_cannot_change_a_path_of_a_secret_source` (macOS, in a real sandbox).
- Neither interpreter changes a protected path, also an absent one under another case of its name, or a link on the way: `a_path_of_a_secret_source_cannot_change_through_an_interpreter`, `a_link_on_the_way_to_a_path_of_a_secret_source_cannot_change_through_an_interpreter`, `a_path_of_a_secret_source_refuses_mutation_and_names_its_reason`, `an_absent_path_of_a_secret_source_cannot_change_under_another_case`.
- Both judgements get the protected paths: `the_process_tables_are_the_agent_each_tool_and_each_stdio_mcp_server`, `offline_schema_generation_reads_a_server_whose_secret_names_a_declared_scheme`.
- The shape of an entry: `a_reads_or_deny_entry_that_does_not_name_one_place_is_refused`, `each_reads_and_deny_entry_is_a_protected_path_of_its_scheme`.
- A file that an argument names is protected, an element that names no file is not held, and a file that Box cannot open is refused by name: `a_file_that_a_secret_source_argument_names_is_protected`, `an_argument_file_that_cannot_be_opened_is_refused_by_name`.
- A table that holds a vault credential is refused, and the refusal holds no value: `a_process_table_that_holds_a_vault_credential_is_refused`, `each_set_pass_secret_env_variable_is_a_vault_credential`.
- A placeholder under the name of a vault credential passes: `a_placeholder_under_the_name_of_a_vault_credential_passes`, and `a_workload_holds_a_placeholder_under_the_name_of_a_vault_credential` (macOS).
- Each refusal comes before the first start of a program: `a_grant_over_a_path_of_a_source_is_refused_and_starts_no_program`, `a_write_grant_over_an_argument_file_of_a_source_is_refused_and_starts_no_program`, `a_table_that_holds_a_credential_of_a_vault_is_refused_and_starts_no_program`, and through the binary `a_grant_over_a_path_of_a_secret_source_is_refused`, `a_table_that_holds_a_credential_of_a_vault_is_refused`, and `generate_schema_refuses_a_table_that_exposes_a_secret_source`.
|
Assessment: Comment I reviewed head Assumptions and rules checked that held
The protections are thorough and well tested, and the limits page states each remaining gap clearly. |
## Problem `SecretSources` copied the operator's value of each `pass-secret-env` variable when the sources opened, and kept each copy until the run ended. Only `SecretSources::refuse_exposure` reads the copies, and it runs one time, before the first program starts. So the trusted process held a second plaintext copy of each credential of a vault for the whole run. It had no use for the copy after that check, and no step wiped it. The `credentials` crate wipes its own copy of the same values. ## Solution - `SecretSources` holds the checked declarations (`DeclaredSources`) in place of the values. A declaration holds names and prefix entries, and no value. `SecretSources::over` runs the check of the tables two times, because the backend takes each declaration. - `SecretSources::refuse_exposure` reads the operator's environment when it runs, builds the `VaultCredential` list, judges each table, and drops the list before it returns. A configuration that declares no source reads no variable. - `VaultCredential` holds its value in `CopiedValue`, which writes a zero over each byte as it drops (`wipe`). `DeclaredSources::vault_credentials` puts each value of the environment snapshot in a `CopiedValue`, so the value of a variable that no source owns is wiped too. `strands-box` does not depend on `zeroize`, so `wipe` is its own volatile write and compiler fence. `Cargo.lock` and the `credentials` crate do not change. - `VaultCredential` is not `Clone`, `PartialEq`, or `Eq` now, so no code copies or compares a credential outside this check. No interface moves. Box now reads the environment in `refuse_exposure`, which each caller runs right after `open`. So the step of startup is the same, and each refusal has the same words. Not changed: Box removes no variable from its own environment. So the trusted process still holds each value in its environment for the whole run. After the check, Box keeps no copy of its own. ## Tests In an Amazon Linux 2023 container (x86_64, Rust 1.98.1): - `cargo test -p strands-box --all-features --locked --lib --no-fail-fast`: 1,156 passed and 16 failed. The same 16 fail on the commit before this one, because of container limits, in `run::broker`, `run::contain`, and `run::hosted`. - `the_sources_read_each_credential_of_a_vault_when_they_judge_a_table` judges one table with one `SecretSources` beside four operators, and gets a refusal, a pass, a refusal that names another variable, and a pass. So each result comes from the environment of its own call. The same test shows that a configuration with no source does not read the environment. - `a_table_that_holds_a_credential_of_a_vault_is_refused_and_starts_no_program` now gives the operator's variables to each check, and the refusal has the same words as before. - `a_wipe_writes_a_zero_over_each_byte_of_a_copied_value` pins `wipe`. No test can observe the wipe of a value that drops. - 4 undo patches, and each one made its test fail: - a copy that is made when the sources open, - a copy that stays after the first check, - a read of the environment with no source declared, - a wipe that writes no zero. - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` and `cargo fmt --all --check` are clean. The five doc guards passed (37 tests). On macOS (arm64, Rust 1.96.0), on the same tree: - `cargo test -p strands-box --all-features --locked --test box_credentials`: 36 passed and 1 ignored. These tests start a real box: `a_table_that_holds_a_credential_of_a_vault_is_refused` and `a_workload_holds_a_placeholder_under_the_name_of_a_vault_credential` read the variables of the real process environment. - The unit tests of `run::secret_sources` and `record::config::secret_source`: 34 passed. Not run: the full workspace suite, which CI runs.
…-protect This brings in two commits: the one that finds the scheme of a secret reference through the credentials locator, and the one that checks the secret sources in one place, before the record commits. `SecretSources::refuse_exposure` is now a private step of `SecretSources::check`, in place of `refuse_writable_programs`. So `command/run.rs` and `command/policy.rs` name no step of the check, and each refusal of this branch comes before Box stores the record of a new box directory. No refusal text changes. Eight files had a conflict, and each other file merged with no change by hand: - `crates/box/src/run/secret_sources.rs` and its tests: the three types of the merged branch, with `refuse_exposure`, `refuse_exposure_in`, and the checked declarations of this branch inside them. Each test of this branch keeps its asserts, and calls the private steps through the test doors of the `tests` module. - `crates/box/src/command/run.rs` and `crates/box/src/command/policy.rs`: the callers of the merged branch. The comment in `prepare_contract` names each table that lets a workload go around a source. - `crates/box/src/record/config/secret_source.rs`: the module table lists `routed_scheme` beside `ProtectedPath` and `VaultCredential`. - `crates/box/tests/box_credentials.rs`: the tests of both branches. - `crates/box/AGENTS.md` and `docs/design/architecture.md`: the bullets and the startup steps of the merged branch, with the refusals of this branch in the check. ## Tests On this commit, in an Amazon Linux 2023 container (x86_64, Rust 1.98.1): `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` and `cargo fmt --all --check` are clean, and the five doc guards passed (37 tests). `cargo test -p strands-box --all-features --locked --lib --no-fail-fast` passed 1,164 tests and failed 16 in one run, and 1,165 and 15 in a second run. Each failure is one of the 16 tests that fail in this container on the commit before this stack, because of container limits, and some of the 16 pass in some runs. On macOS (arm64, Rust 1.96.0), on a tree that differs from this one by one bullet of `docs/user/config.md` and one comment of a test: `box_credentials` passed 38 tests and ignored 1, `mcp_schema_generation` passed 27, and the 40 unit tests of `run::secret_sources` and `record::config::secret_source` passed. 15 undo patches for the checks of this branch that the merge moved: each made its test fail. 12 ran in the container and 3 on macOS, on that same tree.
…-protect This brings in the commit that gives `policy generate-schema` its own secrets type, `SchemaSecrets`. Four files had a conflict, and each one takes the change of the merged commit beside the text of this branch: `crates/box/src/run/secret_sources.rs` and its tests, the comment in `crates/box/src/command/run.rs`, and the order bullet of `crates/box/AGENTS.md`, which names `refuse_exposure` here. ## Tests On this commit, in an Amazon Linux 2023 container (x86_64, Rust 1.98.1): `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` and `cargo fmt --all --check` are clean, and the five doc guards passed (37 tests). `cargo test -p strands-box --all-features --locked --lib --no-fail-fast` passed 1,165 tests and failed 16. The 16 are the tests that fail in this container on the commit before this stack, because of container limits. The 7 undo patches of the merged commit each made their test fail on this tree too. Not run: macOS. CI runs the tests of `policy generate-schema` there.
|
Assessment: Comment I re-reviewed head Checked on this head, and held
|
…-protect This brings main into this branch, through the merge of the branch below. Five files had a conflict. - crates/box/src/command/run.rs, the comment above the check of the secret sources in `prepare_contract`: the merge keeps this branch's words for what the check refuses, and the call of `settle_tools` from the branch below. - docs/design/architecture.md, step 2 of the startup order: the merge keeps this branch's list of what the check refuses, and the sentences about a left-out tool from the branch below. - crates/box/src/record/config/filesystem.rs, `direct_grants`, two hunks: main (#429) added the `deny_write` list where this branch added the check of each entry against the paths of a secret source. The merge keeps both. A `deny_write` entry authorizes nothing, as a `deny` entry, so it does not pass through that check. It needs a `write` tree around it, and that tree is refused when it reaches a path of a source. - crates/box/tests/box_credentials.rs: the branch below added a test where this branch added its tests. The merge keeps each test. - docs/user/config.md, "What Box protects": the branch below changed the paragraph about the program file, and this branch wrote that section again. The merge keeps this branch's section, with the words about a left-out tool in its first paragraph. `a_deny_write_entry_is_judged_against_no_path_of_a_secret_source` pins that rule, and `crates/box/AGENTS.md` and `docs/user/config.md` state it. `docs/user/config.md`, "What Box protects", also says that `run` checks the tables of the tools that it keeps, and that `policy generate-schema` leaves no tool out. `crates/box/AGENTS.md` also says that a list or a value of a left-out tool refuses no run, because this branch adds the check of the values.
…-protect This brings the rebased commits of feature/secret-source-command into this branch, through the merge of the branch below. They have the same content as the commits of it that this branch holds. This merge changes no file: its tree is the tree of its first parent.
…-protect This brings main into this branch, through the merge of the branch below. main now holds the change of feature/secret-source-command as one squashed commit (#489), with the same content as the commits of it that this branch holds, so each file of crates/credentials stays as this branch has it. The merge also brings six files under .agents/ from main (#521). No other file changes.
## Problem Box copied the operator's value of each `pass-secret-env` variable when a run started. It then refused a process table whose `env` or `command` held one of those values, and wiped the copies. The review of this pull request asked to drop the check (comment 4621726233): - It catches one case: an operator who writes the credential of the vault into `box.toml`. Box composes the environment of each workload, so no workload gets that credential in another way. - It misses the same credential in another form, such as Base64. - It costs a second copy of each credential in memory, a wipe with one `unsafe` line, and the tests of both. ## Solution Remove `VaultCredential`, `VaultCredential::refuse_held`, `CopiedValue`, `wipe`, and `DeclaredSources::vault_credentials`. `SecretSources::refuse_exposure` takes no environment and reads no variable of the operator. `SecretSources` no longer holds the checked declarations, so `open` and `checked` take them by value again, as before this pull request. The name rule stays as it is: Box refuses an `env://NAME` or `secret://NAME` reference when a `pass-secret-env` entry names `NAME`, so no route and no telemetry target can send the credential of the vault out. `pass-secret-env` stays the list of variables that Box passes to the source program. Interface: the refusal "holds the value of the variable <NAME>, which is a credential of the secret source" no longer exists. No key, record, or version changes. The docs now state the limit: Box does not look for a `pass-secret-env` value in a table of `box.toml`. The design page `team/designs/0006-secret-providers.md` said "Box refuses a workload environment that holds the operator's value of one of them, under any name". That sentence now says what Box does. ## Tests Linux x86_64 (an Amazon Linux 2023 container), on the tree of this commit: - `cargo fmt --all --check`, `cargo build --workspace --all-features --locked`, and `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` pass. The clippy gate refuses dead code, so it proves that each item with no caller left is gone. - The five doc guard targets pass: `site_manifest`, `documented_inputs`, `four_inputs`, `documented_commands`, `credential_method_scope` (38 tests). - `cargo test -p strands-box --all-features --lib`: 1,205 passed, 5 failed, 1 ignored. The commit below this one: 1,211 passed, the same 5 failed, 1 ignored. By name, the one difference is the six removed tests. The 5 failures are the same on `main` in this container: two `kernel::tests::fallback` tests, `a_leafs_shebang_resolves_past_the_alias_directory`, and two `native_enforcement::probe` tests. - `strands-box-credentials`: 297 and 33 passed. `strands-box-telemetry`: 107 passed, and `the_vault_attaches_a_credential_on_an_ipv6_address` fails here and on `main`, because the container has no IPv6 loopback. Removed with the code: `each_set_pass_secret_env_variable_is_a_vault_credential`, `a_wipe_writes_a_zero_over_each_byte_of_a_copied_value`, `a_process_table_that_holds_a_vault_credential_is_refused`, `a_placeholder_under_the_name_of_a_vault_credential_passes`, `a_table_that_holds_a_credential_of_a_vault_is_refused_and_starts_no_program`, `the_sources_read_each_credential_of_a_vault_when_they_judge_a_table`, and the macOS test `box_credentials.rs::a_table_that_holds_a_credential_of_a_vault_is_refused`. `mcp_schema_generation.rs::generate_schema_refuses_a_table_that_exposes_a_secret_source` keeps its case of a grant that reaches a `reads` path and loses its case of a value. The name rule still refuses, and these tests pass unchanged: `secret_source::tests::a_pass_secret_env_entry_names_the_credential_of_its_source`, `egress::tests::a_reference_to_the_credential_of_a_declared_source_is_refused`, `telemetry::tests::a_reference_to_the_credential_of_a_declared_source_is_refused`. `box_credentials.rs::a_workload_holds_a_placeholder_under_the_name_of_a_vault_credential` stays. It proves that the source program gets the operator's value and that the workload's environment holds the value of its own table. Not run on this commit: the macOS tests. A secret source loads on macOS only, so the binary tests of this change run there, on the last commit of this series.
…rguments
## Problem
Box held each later element of a secret source `command` that was the absolute path of a regular file, such as the script in `["/bin/sh", "/Users/me/tools/vault.sh", "{ref}"]`. It refused a write grant over that file, and the interpreters refused a change to it. The review of this pull request asked to remove that (comment 4621726441):
- Neither shipped plugin names a file in its arguments: `op read op://{ref}` and `aws secretsmanager get-secret-value ...`.
- The hold has gaps that it cannot close: a path inside `--config=/etc/vault.hcl`, a folder, and a file that the interpreter loads by itself.
- It is the reason why the pull request below this one could not merge alone.
## Solution
The program, element 0 of `command`, is the one file of a secret source that Box protects. Remove `ConfiguredCommands::source_files`, `ConfiguredCommand::named_file`, `ConfiguredCommand::over`, the `argument` flag, and the loop over the later elements in `ConfiguredCommands::of_secret_sources`. `ConfiguredCommand::load`, `validate_reach`, and `refusal` are as they were before this pull request.
The protection of the program does not change: Box refuses a write grant over the program file, a symbolic link on the way to it, or a folder that holds one of them, and Strands Shell and Monty refuse a change to them.
Interface: two refusals no longer exist, "this write grant can change <path>, a file that the `command` of [secret-source.<scheme>] names" and "the file <path>, which its `command` names, cannot be opened". A configuration that they stopped now loads.
The docs now say that Box does not protect a file that an argument names, and that an operator who needs a script makes it the program.
## Tests
Linux x86_64 (an Amazon Linux 2023 container), on the tree of this commit:
- `cargo fmt --all --check`, `cargo build --workspace --all-features --locked`, and `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` pass. The clippy gate refuses dead code, so it proves that each item with no caller left is gone.
- The five doc guard targets pass: `site_manifest`, `documented_inputs`, `four_inputs`, `documented_commands`, `credential_method_scope` (38 tests).
- `cargo test -p strands-box --all-features --lib`: 1,202 passed, 5 failed, 1 ignored. The commit below this one: 1,205 passed, the same 5 failed, 1 ignored. By name, the one difference is the three removed tests. The 5 failures are the same on `main` in this container: two `kernel::tests::fallback` tests, `a_leafs_shebang_resolves_past_the_alias_directory`, and two `native_enforcement::probe` tests.
- `strands-box-credentials`: 297 and 33 passed. `strands-box-telemetry`: 107 passed, and `the_vault_attaches_a_credential_on_an_ipv6_address` fails here and on `main`, because the container has no IPv6 loopback.
Removed with the code: `a_file_that_a_secret_source_argument_names_is_protected`, `an_argument_file_that_cannot_be_opened_is_refused_by_name`, `a_write_grant_over_an_argument_file_of_a_source_is_refused_and_starts_no_program`.
The program still has its protection, and these tests pass unchanged: `commands::tests::a_secret_source_program_is_protected_like_a_configured_tool_command` (a write grant, and a change through an interpreter), `commands::tests::each_link_on_the_way_to_a_secret_source_program_is_protected`, `secret_sources::tests::a_write_grant_over_a_source_program_is_refused_and_starts_no_program`.
Not run on this commit: the macOS tests, which run on the last commit of this series.
… in the interpreters ## Problem Strands Shell and Monty refused a change at a `reads` or `deny` path of a secret source, inside it, or above it. To do that, `ConfiguredCommands` matched each mutation against those paths by spelling, by on-disk identity, by a case-folded spelling for a path that is absent, and against each symbolic link on the way. The review of this pull request asked to take that out (comments 4621726643 and 4621802834): - It is a second path matcher behind the interpreters' hook, with case folding, links, and absent paths, and `limitations.md` still listed gaps in it (two Unicode forms of one name, and each read). - A floor beneath policy is the place for this. An open pull request (#434) builds that floor for the well-known credential stores, for reads and for changes. A vault at another path is the job of the operator's policy. ## Solution Remove `ConfiguredCommands::source_paths` and `source_links`, the three checks in `mutation_refusal` that used them, `CommandMutationRefusal::SourcePath`, its reason text in `run/broker/reach.rs`, and `folded`. `ConfiguredCommands::load` and `of_secret_sources` hold the programs alone, as before this pull request. What stays is the sandbox side, with no changed line: - Box refuses a grant of the agent, a tool, or a local MCP server that reaches a `reads` or `deny` path, and a write grant over the folder of a symbolic link on the way to one (`filesystem::require_outside_source_paths`), before a source program starts. - Each sandbox denies those paths. - The interpreters still refuse a change to the program of a source. Stated limit: with a declared source, Strands Shell and Monty do not refuse a read or a change of a `reads` or `deny` path, or a change of a symbolic link on the way to one. Policy decides, as it does on `main` for any path. `docs/user/config.md` ("What Box protects"), `docs/design/limitations.md`, and `docs/design/credentials.md` say so, with what an operator can do today: a path condition on each `fs:*` permit and a `forbid` rule for the paths of the vault. This change adds no folder to the credential store list of `containment`. Interface: the refusal "is at, inside, or above a path that a secret source keeps from each workload, or a link on the way to one" no longer exists. The design page `team/designs/0006-secret-providers.md` said "These protections must also cover the hosted Shell and Python paths". That sentence now says what Box does. ## Tests Linux x86_64 (an Amazon Linux 2023 container), on the tree of this commit: - `cargo fmt --all --check`, `cargo build --workspace --all-features --locked`, and `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` pass. The clippy gate refuses dead code, so it proves that each item with no caller left is gone. - The five doc guard targets pass: `site_manifest`, `documented_inputs`, `four_inputs`, `documented_commands`, `credential_method_scope` (38 tests). - `cargo test -p strands-box --all-features --lib`: 1,199 passed, 5 failed, 1 ignored. The commit below this one: 1,202 passed, the same 5 failed, 1 ignored. By name, the difference is the three removed tests and one test that has a new name. The 5 failures are the same on `main` in this container: two `kernel::tests::fallback` tests, `a_leafs_shebang_resolves_past_the_alias_directory`, and two `native_enforcement::probe` tests. - `strands-box-credentials`: 297 and 33 passed. `strands-box-telemetry`: 107 passed, and `the_vault_attaches_a_credential_on_an_ipv6_address` fails here and on `main`, because the container has no IPv6 loopback. macOS (arm64, Rust 1.96.0), on the tree of this commit: `box_credentials` 38 passed and 1 ignored, `mcp_schema_generation` 27 passed, `run_config` 26 passed. The unit tests of `run::secret_sources`, `run::credential`, `record::config`, and `command` passed (360), and those of `run::commands`, `run::broker::reach`, `run::contain::boundary`, and `record::config::filesystem` passed (164). A secret source loads on macOS only, so these binary tests cover all three commits of this series. Removed with the code: `a_path_of_a_secret_source_cannot_change_through_an_interpreter`, `a_link_on_the_way_to_a_path_of_a_secret_source_cannot_change_through_an_interpreter`, `an_absent_path_of_a_secret_source_cannot_change_under_another_case`. Two tests now pin the stated limit, so they fail when a floor in `Reach` refuses one of these paths: - `reach.rs::the_interpreters_leave_a_path_of_a_secret_source_to_policy` (it was `a_path_of_a_secret_source_refuses_mutation_and_names_its_reason`). A change at a `reads` path, inside it, at an absent `deny` path, and above it passes the reachable paths check, and a change to the program of the same source is refused. An undo patch that puts a stand-in floor under the interpreters makes it fail. - `box_credentials.rs::a_tool_cannot_see_a_path_of_a_secret_source_and_policy_decides_the_shell` (macOS, a real sandbox; it was `a_tool_cannot_see_and_the_shell_cannot_change_a_path_of_a_secret_source`). A tool cannot see a file under a `reads` path. With a permit for `fs:write`, the Shell changes that file. A `forbid` rule keeps a file under the `reads` path of a second source. The sandbox side still refuses, and these tests pass unchanged: `filesystem::tests::a_grant_that_reaches_a_path_of_a_secret_source_is_refused`, `a_grant_that_reaches_a_path_of_a_secret_source_through_a_link_is_refused`, `a_grant_that_reaches_an_absent_path_of_a_secret_source_is_refused`, `a_credential_store_of_a_secret_source_is_refused_when_named_exactly`, `boundary::tests::each_boundary_refuses_each_path_of_a_secret_source`, `secret_sources::tests::a_grant_over_a_path_of_a_source_is_refused_and_starts_no_program`, and on macOS `box_credentials.rs::a_grant_over_a_path_of_a_secret_source_is_refused`. Three undo patches on this tree, one for each protection that stays in this series, each made its tests fail: the name rule finds no owner of a variable (3 tests), the source programs are left out of the protected files (4 tests), and a grant is not judged against the `reads` and `deny` paths (7 tests). Not run: the full workspace suite, the Linux sandbox suites, and a real `op` or `aws`.
|
Assessment: Comment I re-reviewed head Checked on this head, and held
|
…bid rule compares Two comments of the automated review on this pull request, both on docs. - `team/designs/0006-secret-providers.md` is a snapshot that a person wrote, and the repository rules keep it out of updates. The two sentences that the removal commits changed are back as they were. `docs/design/limitations.md` and `docs/user/config.md` state where this pull request departs from the design. - The `forbid` example in `docs/user/config.md` compares each letter exactly, so it does not match another case of a name. The text now says so, and says that the path conditions of the `fs:*` permits are the protection. `docs/design/limitations.md` says the same. No code changes. The five doc guard targets pass.
|
Assessment: Comment I re-reviewed head Checked on this head, and held
|
ferdingler
left a comment
There was a problem hiding this comment.
Thanks Anand, this is much simpler now. Dropping the value check and the argument files makes sense, and the Shell and Monty protection can come from the policy floor in #434 once you've talked to Priya.
|
Assessment: Comment I re-reviewed head Checked on this head, and held
The interface changes the PR lists still need a maintainer's approval. |
Description
This is the fourth of four stacked PRs that build the secret provider design (#467). It is stacked on #500, which reads each declared secret at startup, so its diff shows only this step.
After #500, Box runs each declared program and delivers its secret. Nothing yet stops a workload from taking a grant over the vault's own files and reading the vault around Box. This PR adds that refusal. It is macOS only, as the table is.
A
[secret-source.<scheme>]table lists the vault's own paths inreadsanddeny. Box now refuses a grant in[agent], in a[tool.<name>]table that the run does not leave out, or in a stdio[mcp.<name>]table when the grant reaches one of those paths: at the path, inside it, or above it, in each list that authorizes. A credential store that a grant can otherwise name exactly, such as~/.aws, has no exception here. An absent path and a symbolic link do not hide the overlap, and a write grant over the folder of a symbolic link on the way to a path is refused too. Box makes this check before it starts a source program for the first time, inrunand inpolicy generate-schema, so a box that it refuses never runs the program. In a box that starts, each sandbox denies those paths, also a path that appears later.An operator writes this:
and the box does not start, and the program does not run. The line below is from a real run on macOS with a stand-in program, on an earlier head of this PR.
<probe>is the folder of the run, and itsopchomeis theHOMEof the run. The testa_grant_over_a_path_of_a_secret_source_is_refusedasserts the same text on this head:A
readsordenyentry must name one place, so an entry with.., a second/after~, a control character, or a pattern character is refused when the configuration loads. An operator who declares no source sees no change.What left this PR after review
Three parts of the first version are gone. Each one has its own commit.
pass-secret-envvalues (comment). Box no longer copies the operator's values and no longer refuses a table whoseenvorcommandholds one. Box composes the environment of each workload, so a workload holds such a value only when the operator writes it inbox.toml. The name rule of feat(box): load, check, and store a secret source declaration #499 stays: noenv://NAMEorsecret://NAMEreference can read apass-secret-envvariable.commandnames (comment). The program, element 0 ofcommand, is the one file that Box protects. An operator who needs a script makes it the program. So feat(box): read each declared secret at startup and deliver it #500 no longer needs to merge together with this PR.readsordenypath, or a change of a symbolic link on the way to one. That protection belongs in a floor beneath policy, which fix(box): refuse credential stores beneath the Shell and Monty floor #434 builds for the well-known credential stores. This PR adds no folder to that list.Interface changes
Each change below needs a maintainer's approval. No key, record field, record version, startup line, or crate surface moves.
readsordenypath is refused, onrunand onpolicy generate-schema. So is a write grant over the folder of a symbolic link on the way to one.readsanddenypath.readsordenyentry with.., a second/after~, a control character, or a pattern character is refused when the configuration loads. When Box judges the lists of a process table, it also refuses an entry whose symbolic links do not end, or whose path it cannot inspect. feat(box): read each declared secret at startup and deliver it #500 loaded such an entry.pass-secret-envvariable, and that the protections also cover the hosted Shell and Python. After the review, Box does neither. The design page is a snapshot and does not change.docs/design/limitations.mdanddocs/user/config.mdstate both points.Known limits
readsordenypath, or a change of a symbolic link on the way to one. They run outside every sandbox, and policy alone decides a read or a change there, as it does onmain. With a rule that permitsfs:writeon~/.aws/config, a workload can change that file through the Shell, and a changed settings file can change what the source program runs. What an operator can do today: give eachfs:*permit a path condition, and write aforbidrule for the paths of the vault.docs/user/config.mdshows the rule, and says how to write it for a path behind a symbolic link. fix(box): refuse credential stores beneath the Shell and Monty floor #434 is the planned place for the well-known stores, and a vault at another path stays the job of the operator's policy. The 1Password folders are not in the store list today. Adding them is planned after this stack. The teststhe_interpreters_leave_a_path_of_a_secret_source_to_policyanda_tool_cannot_see_a_path_of_a_secret_source_and_policy_decides_the_shellpin this limit, so they fail when a floor inReachrefuses one of these paths.pass-secret-envvariable in a table ofbox.toml, in the arguments typed afterrun, or in a file that a workload can read.reads, so that no grant reaches it.readsordenypath by its name and by the file at that name. It does not search for hard links.deny_writeentry (feat(box, containment): deny writes to a directory inside a write grant, in every process #429) grants nothing, so Box does not compare it with thereadsanddenypaths. It must lie inside awriteentry, and Box refuses thatwriteentry when it reaches one of those paths.policy generate-schemastarts each stdio MCP server with no sandbox, with or without a secret source. A server that it starts can read and change thereadspaths and the program of a source.docs/design/limitations.mdstates these limits, apart from the one aboutdeny_write, which is indocs/user/config.md. The full rules are indocs/user/config.md, in the section "What Box protects".Related Issues
Type of Change
New feature
Testing
On this head, which holds
mainat37af6316through a merge:cargo fmt --all --check,cargo build --workspace --all-features --locked, andcargo clippy --workspace --all-targets --all-features --locked -- -D warningsare clean. The five doc guards passed.cargo test -p strands-box --all-features --locked --lib --no-fail-fast: 1,199 passed, 5 failed, and 1 ignored. Each failure is one of the 5 tests that fail in this container onmain, by name: two need thehostnameprogram, which the container does not have, one runs a script through a program that is acoreutilslink in the container, and two make a kernel probe that the container refuses.box_credentials38 passed and 1 ignored,mcp_schema_generation27 passed, andrun_config26 passed. The unit tests ofrun::secret_sources,run::credential,record::config, andcommandpassed (360), and those ofrun::commands,run::broker::reach,run::contain::boundary, andrecord::config::filesystempassed (164). Thebox_credentialstests start real sandboxes: a tool cannot see a file under areadspath, the Shell changes that file when policy permits the write, and aforbidrule keeps the file of a second source.readsanddenypaths. A fourth one puts a stand-in floor under the interpreters, and the test of the stated limit fails.export::tests::the_vault_attaches_a_credential_on_an_ipv6_address. It fails in the same way onmain, because the container has no IPv6 loopback.Before the three removal commits, and not repeated:
mainat6f4a2e36:box_credentials28 passed and 1 ignored,mcp_schema_generation21 passed,run_config26 passed, andtool_grammars18 passed, with no skipped test. On Linux, Box refuses a secret source table, so the tests of this PR run on macOS only.deny_writerule made its test fail.egress-gatewayunit test in a crate that this change does not touch. It then passed 3 times alone on that revision and 3 times onmain.op2.42.0 and the realaws2.27.52. The agent held a placeholder,gh api userreturned the login,opas a declared tool in the box could not reach~/.config/op, and no file held the token.Not run on this head: the full workspace suite (CI runs it), the Linux sandbox suites, and a real
oporaws.just check, orcargo test --workspace --all-features)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.