Skip to content

docs: make a secret provider a plugin - #467

Merged
yesyayen merged 3 commits into
mainfrom
feature/secret-provider-plugins
Nov 18, 2026
Merged

yesyayen merged 3 commits into
mainfrom
feature/secret-provider-plugins

Conversation

@yesyayen

@yesyayen yesyayen commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • A provider is a plugin, not a pack. A provider makes Box run a host program such as op outside every sandbox. No pack does that. The profile lists it in its own plugins list. This follows the plugin thread on #395.
  • Plugin rules. Only the profile lists a plugin. No pack can pull one in, and no pack can declare [secret-source.<scheme>] or name a reference in a declared scheme. box profile show and startup print each plugin and its program.
  • One command array. The program comes first, then its arguments, as in [agent], [tool], and [mcp]. The args key is gone.
  • {ref} is defined. It is the text after scheme://, so the 1Password plugin writes op://{ref}.
  • No takeover of built-in schemes. A plugin cannot declare env, file, aws, credsd, or another reserved scheme. One scheme has one declaration.
  • Telemetry and #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.
  • Two pass lists. pass-env holds plain settings such as AWS_REGION. pass-secret-env holds credentials. Box keeps their real values out of every workload, and it refuses an env:// reference to one of them.
  • output = "json". The program can print the secret as one JSON string. Box then refuses a binary secret.
  • Fetch order. Box fetches telemetry secrets first, then opens the collector, then fetches the rest.
  • One secret per placeholder variable, and Box fetches each secret once.
  • protocol is the version hook. A later version can return an expiry with the secret.

How a profile looks now:

packs   = ["box/claude", "box/anthropic"]
plugins = ["box/1password"]

[egress.anthropic.secret]
ref = "op://Private/Anthropic/credential"
env = "ANTHROPIC_API_KEY"

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.

  • I ran the relevant suites (just check, or cargo test --workspace --all-features)
  • If I touched Rust, I ran cargo fmt --all and cargo clippy --workspace --all-targets --all-features -- -D warnings

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

## 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.
@github-actions github-actions Bot added Area - Egress/Creds Area - Release documentation Improvements or additions to documentation labels Nov 16, 2026
@yesyayen
yesyayen marked this pull request as ready for review November 16, 2026 19:31
Comment thread team/designs/0006-secret-providers.md Resolved
Comment thread team/designs/0006-secret-providers.md Resolved
@github-actions

Copy link
Copy Markdown

Assessment: Comment

The change from pack to plugin, the single command array, the definition of {ref}, and the refusal of reserved schemes read well. The two inline findings come from places where the new examples meet startup paths that already exist: the restricted provider environment against the AWS default chain and workload AWS_REGION, and the shared fetch against the current order of telemetry and vault startup.

Checked and held
  • {ref} = the text after scheme://: this is correct for op://Vault/Item/field, op://…?attribute=otp, and AWS secret names and ARNs. Neither vendor's reference syntax allows #, so removing #FIELD cannot cut off part of a reference.
  • The reserved schemes match the code: env/file/op/aws/credsd/cmd/oauth2 (credentials), the aws-signed sentinel, and secret://. One gap: secret:// is the box crate's TELEMETRY_ALIAS_SCHEME, not a credentials constant, so "the credentials crate owns this list" needs that one exception.
  • "One placeholder variable holds one secret": configs that are valid today, where several routes name the same env://NAME, keep the same reference and are still accepted.
  • "Refuse a JSON object without #FIELD": this matches feat(credentials): read a secret from AWS Secrets Manager #448's a_whole_json_object_is_refused.
  • A declared op replaces the built-in source rather than registering a second one: this agrees with duplicate_scheme_is_refused.
  • Not verified: the plugin, pack, and profile claims (program inputs, [options], extends, [pack] header keys). Box CLI is not in this repository.

- 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.
Comment thread team/designs/0006-secret-providers.md Resolved
@github-actions

Copy link
Copy Markdown

Assessment: Comment (re-review of cae44bf)

cae44bf resolves both findings from the first review. The new pass-env/pass-secret-env split, output = "json", and the two-step fetch hold for the cases I traced. One new Important comment remains, inline: on Box's own EKS (Pod Identity) deployment, the AWS plugin falls back to the node role.

Checked and held at this head
  • pass-env vs pass-secret-env: all the shipped examples that set AWS_REGION in a workload env are now accepted. The AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY placeholders of signed aws:// routes (SIGNING_PLACEHOLDERS) are explicitly allowed. Exported keys from aws-vault exec now reach the child.
  • output = "json": a binary secret gives null, and Box refuses it. A JSON string with #FIELD decodes and then extracts one field, as intended.
  • Two-step fetch: this matches today's order, where telemetry::open runs before HostedBox::open. Egress fetch failures are still recorded. A telemetry-secret failure goes to stderr, as the doc now states.
  • backends.auth.ref accepts a declared scheme, and a re-routed entry's own secret stays env:// only. This agrees with the phantom-only rule in docs/user/egress.md.
  • A pack that writes a reference in a declared scheme is refused, and a reference that starts with - is refused. Neither affects an input that is valid today.
  • The reserved-scheme list is now owned by Box Core, which covers the box crate's secret://.
  • "Existing configurations keep their behavior": each new refusal applies only when a provider is declared.

…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.
@github-actions

Copy link
Copy Markdown

Assessment: Approve (re-review of 6619014)

6619014 resolves the last open finding, so the AWS plugin's identity now matches a bare aws:// route in every case I traced. I have no new findings.

Checked and held at this head
  • EKS Pod Identity / IRSA / ECS: the container and web-identity variables are passed, and the token directories are in reads. The child gets the same role as DefaultCredentialsChain.
  • Laptop or EC2 with AWS_EC2_METADATA_DISABLED unset: both the child and a bare aws:// route can reach instance metadata, so they get the same identity.
  • ARN in another region: the doc now states the limit (the aws CLI does not read the region from an ARN).
  • New refusal of env://NAME or secret://NAME for names in pass-secret-env: it applies only when a provider is declared. Egress and MCP secret.ref accept no file://, so a token file in reads can't be sent out through another scheme. One gap: the rule names "route or telemetry target", and a backend's auth.ref = "env://NAME" is read as a route.
  • Not verifiable here: the plugin, pack and profile claims, because Box CLI is outside this repository.

@yesyayen
yesyayen enabled auto-merge (squash) November 16, 2026 23:24
yesyayen added a commit that referenced this pull request Nov 17, 2026
…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.
yesyayen added a commit that referenced this pull request Nov 17, 2026
## 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.
yesyayen added a commit that referenced this pull request Nov 17, 2026
…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.
@yesyayen
yesyayen merged commit c0d6c6b into main Nov 18, 2026
18 checks passed
@yesyayen
yesyayen deleted the feature/secret-provider-plugins branch November 18, 2026 04:46
yesyayen added a commit that referenced this pull request Nov 18, 2026
## 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.
yesyayen added a commit that referenced this pull request Nov 18, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - Egress/Creds Area - Release documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants