Repository navigation
docs: make a secret provider a plugin - #467
Conversation
## Problem The secret providers design puts a provider in a pack. A provider makes Box's trusted process run a host program outside every sandbox, which no pack does. The review of #395 agreed that a provider is a plugin, and the merged doc does not say so yet. The doc also does not define `{ref}`. It lets a declared provider replace each built-in source. A telemetry target cannot use a provider. ## Solution - A provider is a plugin that the profile lists in `plugins`. The doc gives the rules that set a plugin apart from a pack, and it shows the `[plugin]` header. - `command` is one array, as `[agent]`, `[tool.<name>]`, and `[mcp.<name>]` write it. The `args` key is gone, and the program is an absolute path. - `{ref}` is the text after `scheme://` in the reference. It can be a part of an argument. - Box refuses a declaration for a reserved scheme, and one scheme has one declaration. - A telemetry target's `secret.ref` accepts a declared scheme, and a reference can name one field of a JSON secret with `#FIELD`. A second plugin, for AWS Secrets Manager, shows both. - One placeholder variable holds one secret, and Box fetches each secret once. - `protocol` names the contract version. A later version can return an expiry with the secret. ## Tests Documentation only, so no suite ran. The four TOML examples in the doc parse. The Mermaid block did not change.
|
Assessment: Comment The change from pack to plugin, the single Checked and held
|
- Split `pass-env`. `pass-env` holds plain settings, such as `AWS_REGION`, and a workload can set the same names. `pass-secret-env` holds credentials. Box refuses a workload value that equals the operator's value of a credential, and it allows a placeholder under the same name. - The Secrets Manager plugin passes the region and the AWS key variables, so exported keys work, such as from `aws-vault exec`. The doc says that the `aws` child finds its own identity. - Add `output = "json"`. A binary secret then prints `null`, and Box refuses it. Box decodes stdout first, and `#FIELD` parses the decoded secret. - Container and web-identity AWS credentials are not passed to the plugin, and the doc says so. - Give the fetch order: telemetry secrets first, then the collector, then the other secrets. A failed telemetry-secret fetch goes to stderr only. - A backend `auth.ref` accepts a declared scheme with no `secret.env`. A re-routed entry's own `secret.ref` stays `env://`. - Box Core owns the reserved scheme list, because `secret` is a box crate alias. - The 1Password plugin passes `OP_ACCOUNT`, the Connect variables, and `OP_SESSION_*`. A name in a pass list can end with `*`. - Box refuses a grant that gives a workload a path in `reads` or `deny`. This also applies to a path that a workload can get by name today. - Box does not refuse a `credential_process` profile, and it does not protect that program. The doc says not to use one with the Secrets Manager plugin. - Only the profile can name a reference in a declared scheme. Box CLI refuses one in a pack. - Box refuses a reference that starts with `-`, so that the program cannot read it as a flag.
|
Assessment: Comment (re-review of
Checked and held at this head
|
…variables - The plugin passes the variables of a container or web identity, such as EKS Pod Identity, and it protects the token files. It also passes `AWS_EC2_METADATA_DISABLED`. The child then gets the identity that a bare `aws://` route gets. - The secret must be in the region that the child is configured for. The `aws` CLI does not read the region from an ARN. - Box refuses an `env://NAME` or `secret://NAME` reference when `NAME` is in a `pass-secret-env` list, so no route or telemetry target can send that credential out.
|
Assessment: Approve (re-review of
Checked and held at this head
|
…ut a field A declared source refuses a secret that is a JSON object when the reference has no `#FIELD`, with each `output`. The built-in `op://` source returns such a secret whole. So a declared `op`, which takes the place of the built-in source, differs from it here. The docs did not say so, and the README row for `text` read as if stdout always passes. The rule stays for each `output`, as the design (#467) states it: one destination never gets each key of an object. A check for `json` alone lets a program that prints an object as text pass it whole. - `a_declared_op_refuses_a_json_object_without_a_field_in_text_output` pins the refusal for scheme `op`. - `returns_a_json_object_whole` pins what the built-in source does with the same stdout. - The README rows for `output` and `#FIELD` state that the rule holds for each `output`, and name the difference.
## Problem The credentials crate reads a secret from a vault only through its built-in `op://` source. A second vault, such as AWS Secrets Manager, needs a new source in the crate, with its own dependencies and its own review. The secret provider design (#467) replaces that with one contract. The caller declares a host program, and the box runs it at startup and reads one secret from its stdout. The crate has no way to run a declared program. ## Solution Add a declared secret source to the credentials crate. Nothing reads it from `box.toml` yet, so a box behaves as before. - `SecretSourceCommand` declares one program for one scheme: the protocol (`box.secret-source.v1`), the command, the output form (`text` or `json`), and two pass lists. Its constructor refuses a reserved or malformed scheme, another protocol, and an empty command. It also refuses a program that is not an absolute path, and a command with no `{ref}` in its arguments. A pass list refuses the entries `*`, `PATH`, and `HOME`, and an entry with a `*` before its end. Each refusal names the key and the entry. - The runner starts the program with no shell and no stdin, in `/`. The environment is `HOME`, `PATH=/usr/bin:/bin`, and each pass-list variable that is set. An entry that ends with `*` passes each variable with that prefix. A run of more than 30 seconds, more than 1 MiB of stdout, or a non-zero exit fails the fetch. A failure carries the end of stderr, at most 512 bytes, with the reference name and each passed `pass_secret_env` value replaced. - `{ref}` (`SECRET_REFERENCE_TOKEN`) is the text after `scheme://` without `#FIELD`. The source replaces it inside each argument, and refuses a reference whose text after `scheme://` starts with `-`. - With `output = "json"`, stdout is one JSON string. With `#FIELD`, the secret is a JSON object, and the source returns that one string field. Without `#FIELD`, a secret that is a JSON object is refused. The JSON field step and its wipe helpers follow #448. - `RESERVED_SECRET_SCHEMES` lists the schemes that no declaration can claim, and `SecretSourceCommand::check_scheme` is the check. - `Backend::declared(declarations)` registers `env`, `file`, and one source for each declaration. A declared `op` takes the place of the built-in `op://` source. The backend keeps each fetched secret, so two references that differ only in `#FIELD` run the program once. Interfaces that moved: - The `pub use` set of the crate grows from 20 names to 23: `SecretSourceCommand`, `SECRET_REFERENCE_TOKEN`, `RESERVED_SECRET_SCHEMES`. - `SecretSourceCommand` has the constant `PROTOCOL` and the functions `new`, `check_scheme`, `output`, `pass_env`, and `pass_secret_env`. - The URI vocabulary of the crate gains `SCHEME://NAME[#FIELD]` for a declared scheme. `#` starts a field only for a declared scheme. - `Backend` gains the constructor `declared`, and is now `Clone`. Each clone shares the same sources and the same fetched secrets. The held secrets have no accessor. - `Backend::local()` is the same: `env`, `file`, and the built-in `op`. ## Tests Each test uses a stand-in program, a shell script in a temp dir. No test runs a real `op` or `aws`. - `cargo test -p strands-box-credentials --all-features --locked`: 292 unit tests and 33 integration tests passed on macOS. 289 unit tests and 33 integration tests passed in an Amazon Linux 2023 container. 55 unit tests are new. - The declaration: `each_reserved_scheme_is_refused_by_name`, `a_command_with_no_reference_token_in_its_arguments_is_refused`, `a_pass_list_entry_that_has_no_effect_or_passes_every_variable_is_refused`. - The environment: `the_program_gets_only_home_the_fixed_path_and_the_passed_variables`, `a_variable_with_a_name_that_is_not_utf8_does_not_pass`. - No stdin, the directory `/`, no shell, `{ref}`: `the_program_gets_no_stdin`, `the_program_starts_in_the_root_directory`, `each_argument_reaches_the_program_as_one_argument_with_no_shell`, `a_malformed_reference_is_refused_before_the_program_starts`. - The bounds: `a_program_that_runs_past_the_timeout_is_stopped`, `stdout_up_to_the_limit_is_read_and_one_more_byte_is_refused`, `a_program_that_never_stops_writing_is_stopped_at_the_limit`, `a_program_that_leaves_its_stdout_open_fails_at_the_deadline`. - The failure text: `a_non_zero_exit_is_a_failure_that_carries_stderr`, `a_failure_hides_the_reference_and_each_passed_credential_and_each_control_character`, `a_failure_hides_a_passed_credential_that_is_not_utf8`, `a_failure_carries_at_most_512_bytes_of_stderr`, `the_excerpt_hides_a_whole_hidden_value_near_the_start_of_a_cut_capture`. - The output and the field: `json_output_is_one_json_string_and_any_other_value_is_refused`, `a_field_selects_one_string_of_a_json_object_and_any_other_case_is_refused`, `a_json_object_without_a_field_is_refused`. - One fetch: `two_references_that_differ_only_in_the_field_run_the_program_once`, `each_clone_of_a_declared_backend_shares_one_fetch`, `two_callers_at_one_time_run_the_program_once`. - The backend: `a_declared_op_takes_the_place_of_the_built_in_source`, `local_holds_the_env_file_and_op_schemes`. - Clippy for the workspace (`--all-targets --all-features -D warnings`) and the rustdoc gate of the crate are clean in the container. Not run: the full workspace suite, because no other crate calls the new surface. No test can observe the wipe of a value that drops, a parsed JSON value or a copied environment value; `a_wipe_empties_each_string_of_a_parsed_value` tests the helper.
…ut a field A declared source refuses a secret that is a JSON object when the reference has no `#FIELD`, with each `output`. The built-in `op://` source returns such a secret whole. So a declared `op`, which takes the place of the built-in source, differs from it here. The docs did not say so, and the README row for `text` read as if stdout always passes. The rule stays for each `output`, as the design (#467) states it: one destination never gets each key of an object. A check for `json` alone lets a program that prints an object as text pass it whole. - `a_declared_op_refuses_a_json_object_without_a_field_in_text_output` pins the refusal for scheme `op`. - `returns_a_json_object_whole` pins what the built-in source does with the same stdout. - The README rows for `output` and `#FIELD` state that the rule holds for each `output`, and name the difference.
## Problem The credentials crate reads a secret from a vault only through its built-in `op://` source. A second vault, such as AWS Secrets Manager, needs a new source in the crate, with its own dependencies and its own review. The secret provider design (#467) replaces that with one contract. The caller declares a host program, and the box runs it at startup and reads one secret from its stdout. The crate has no way to run a declared program. ## Solution Add a declared secret source to the credentials crate. Nothing reads it from `box.toml` yet, so a box behaves as before. - `SecretSourceCommand` declares one program for one scheme: the protocol (`box.secret-source.v1`), the command, the output form (`text` or `json`), and two pass lists. Its constructor refuses a reserved or malformed scheme, another protocol, and an empty command. It also refuses a program that is not an absolute path, and a command with no `{ref}` in its arguments. A pass list refuses the entries `*`, `PATH`, and `HOME`, and an entry with a `*` before its end. Each refusal names the key and the entry. - The runner starts the program with no shell and no stdin, in `/`. The environment is `HOME`, `PATH=/usr/bin:/bin`, and each pass-list variable that is set. An entry that ends with `*` passes each variable with that prefix. A run of more than 30 seconds, more than 1 MiB of stdout, or a non-zero exit fails the fetch. A failure carries the end of stderr, at most 512 bytes, with the reference name and each passed `pass_secret_env` value replaced. - `{ref}` (`SECRET_REFERENCE_TOKEN`) is the text after `scheme://` without `#FIELD`. The source replaces it inside each argument, and refuses a reference whose text after `scheme://` starts with `-`. - With `output = "json"`, stdout is one JSON string. With `#FIELD`, the secret is a JSON object, and the source returns that one string field. Without `#FIELD`, a secret that is a JSON object is refused. The JSON field step and its wipe helpers follow #448. - `RESERVED_SECRET_SCHEMES` lists the schemes that no declaration can claim, and `SecretSourceCommand::check_scheme` is the check. - `Backend::declared(declarations)` registers `env`, `file`, and one source for each declaration. A declared `op` takes the place of the built-in `op://` source. The backend keeps each fetched secret, so two references that differ only in `#FIELD` run the program once. Interfaces that moved: - The `pub use` set of the crate grows from 20 names to 23: `SecretSourceCommand`, `SECRET_REFERENCE_TOKEN`, `RESERVED_SECRET_SCHEMES`. - `SecretSourceCommand` has the constant `PROTOCOL` and the functions `new`, `check_scheme`, `output`, `pass_env`, and `pass_secret_env`. - The URI vocabulary of the crate gains `SCHEME://NAME[#FIELD]` for a declared scheme. `#` starts a field only for a declared scheme. - `Backend` gains the constructor `declared`, and is now `Clone`. Each clone shares the same sources and the same fetched secrets. The held secrets have no accessor. - `Backend::local()` is the same: `env`, `file`, and the built-in `op`. ## Tests Each test uses a stand-in program, a shell script in a temp dir. No test runs a real `op` or `aws`. - `cargo test -p strands-box-credentials --all-features --locked`: 292 unit tests and 33 integration tests passed on macOS. 289 unit tests and 33 integration tests passed in an Amazon Linux 2023 container. 55 unit tests are new. - The declaration: `each_reserved_scheme_is_refused_by_name`, `a_command_with_no_reference_token_in_its_arguments_is_refused`, `a_pass_list_entry_that_has_no_effect_or_passes_every_variable_is_refused`. - The environment: `the_program_gets_only_home_the_fixed_path_and_the_passed_variables`, `a_variable_with_a_name_that_is_not_utf8_does_not_pass`. - No stdin, the directory `/`, no shell, `{ref}`: `the_program_gets_no_stdin`, `the_program_starts_in_the_root_directory`, `each_argument_reaches_the_program_as_one_argument_with_no_shell`, `a_malformed_reference_is_refused_before_the_program_starts`. - The bounds: `a_program_that_runs_past_the_timeout_is_stopped`, `stdout_up_to_the_limit_is_read_and_one_more_byte_is_refused`, `a_program_that_never_stops_writing_is_stopped_at_the_limit`, `a_program_that_leaves_its_stdout_open_fails_at_the_deadline`. - The failure text: `a_non_zero_exit_is_a_failure_that_carries_stderr`, `a_failure_hides_the_reference_and_each_passed_credential_and_each_control_character`, `a_failure_hides_a_passed_credential_that_is_not_utf8`, `a_failure_carries_at_most_512_bytes_of_stderr`, `the_excerpt_hides_a_whole_hidden_value_near_the_start_of_a_cut_capture`. - The output and the field: `json_output_is_one_json_string_and_any_other_value_is_refused`, `a_field_selects_one_string_of_a_json_object_and_any_other_case_is_refused`, `a_json_object_without_a_field_is_refused`. - One fetch: `two_references_that_differ_only_in_the_field_run_the_program_once`, `each_clone_of_a_declared_backend_shares_one_fetch`, `two_callers_at_one_time_run_the_program_once`. - The backend: `a_declared_op_takes_the_place_of_the_built_in_source`, `local_holds_the_env_file_and_op_schemes`. - Clippy for the workspace (`--all-targets --all-features -D warnings`) and the rustdoc gate of the crate are clean in the container. Not run: the full workspace suite, because no other crate calls the new surface. No test can observe the wipe of a value that drops, a parsed JSON value or a copied environment value; `a_wipe_empties_each_string_of_a_parsed_value` tests the helper.
…ut a field A declared source refuses a secret that is a JSON object when the reference has no `#FIELD`, with each `output`. The built-in `op://` source returns such a secret whole. So a declared `op`, which takes the place of the built-in source, differs from it here. The docs did not say so, and the README row for `text` read as if stdout always passes. The rule stays for each `output`, as the design (#467) states it: one destination never gets each key of an object. A check for `json` alone lets a program that prints an object as text pass it whole. - `a_declared_op_refuses_a_json_object_without_a_field_in_text_output` pins the refusal for scheme `op`. - `returns_a_json_object_whole` pins what the built-in source does with the same stdout. - The README rows for `output` and `#FIELD` state that the rule holds for each `output`, and name the difference.
Description
#395 merged the secret providers design before its review feedback went in. This PR adds that feedback to the design doc. It changes only
team/designs/0006-secret-providers.md.What changes in the design:
opoutside every sandbox. No pack does that. The profile lists it in its ownpluginslist. This follows the plugin thread on #395.[secret-source.<scheme>]or name a reference in a declared scheme.box profile showand startup print each plugin and its program.commandarray. The program comes first, then its arguments, as in[agent],[tool], and[mcp]. Theargskey is gone.{ref}is defined. It is the text afterscheme://, so the 1Password plugin writesop://{ref}.env,file,aws,credsd, or another reserved scheme. One scheme has one declaration.#FIELD. A telemetry target can use a provider, and a reference can name one field of a JSON secret. A second plugin, for AWS Secrets Manager, shows both. This covers the telemetry use case of feat(credentials): read a secret from AWS Secrets Manager #448. The plugin passes the AWS identity variables, including the ones for EKS Pod Identity.pass-envholds plain settings such asAWS_REGION.pass-secret-envholds credentials. Box keeps their real values out of every workload, and it refuses anenv://reference to one of them.output = "json". The program can print the secret as one JSON string. Box then refuses a binary secret.protocolis the version hook. A later version can return an expiry with the secret.How a profile looks now:
Related Issues
#395, #448
Type of Change
Documentation update
Testing
Documentation only, so no suite ran. The TOML examples in the doc parse. The Mermaid diagram did not change.
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.