Repository navigation
feat(credentials): sign a bare aws:// with the AWS default credential chain - #342
Conversation
… chain ## Problem A bare `aws://` credential reference did not parse, and a signed route with no profile read only the ambient `AWS_*` environment. An operator could not sign a request with the host execution identity, such as web identity, the container endpoint, or instance metadata, through one familiar spelling. The credentials crate linked no HTTP client, so it could not reach the container endpoint or instance metadata. ## Solution A bare `aws://` reference now resolves the AWS SDK default credential provider chain: the environment, the profile files (including `credential_process`), web identity, the container endpoint, then instance metadata. The credentials crate owns the SDK and the HTTP/TLS stack (`aws-config`, `aws-credential-types`, `aws-smithy-http-client` on `ring`) and a current-thread Tokio runtime. A new private `sources/aws_chain.rs` drives the async chain on a dedicated worker thread and caches the result with an expiry buffer. The synchronous `AwsCredentialProvider` seam sends a request and waits on a channel with a bounded deadline, so the signer stays synchronous and never starts a runtime inside a runtime. The no-profile acquisition is `AwsAcquisition::DefaultChain` and warns on every signed request; `EnvAwsProvider` is deleted, because the chain reads the environment first and subsumes it. `aws://PROFILE` keeps the static-key path unchanged. The box loader accepts a bare `aws://` `secret.ref`. The shipped box exposes no setting that refuses the bare form, so the mitigation is a named profile or keeping `~/.aws` unwritable by the workload; `docs/design/decisions.md` records the default-chain decision and the two decisions it overturns. Two interfaces moved, and both are approved, with their `decisions.md` entries and doc updates in this change: the URI vocabulary accepts a bare `aws://` for the `aws` scheme only, and the credentials crate links the AWS SDK and a TLS stack. The credentials public facade is unchanged at 19 names. A rejected alternative: the box crate owns the SDK and injects a resolver across a sealed seam. It keeps the credentials crate free of an HTTP client, but splits AWS ownership across two crates and adds public surface, so cohesion was chosen instead. ## Tests `cargo test -p strands-box-credentials --all-features` passes 220 unit tests and 27 end-to-end tests. New tests pin each requirement: `parse_uri_accepts_bare_aws`, `the_bare_uri_form_resolves_to_no_profile`, `default_chain_acquisition_warns`, `scoped_profile_acquisition_does_not_warn`, the `RefreshCache` suite (`cache_serves_valid_without_resolving`, `cache_refreshes_within_expiry_buffer`, `cache_serves_stale_valid_on_refresh_failure`, `cache_errors_hard_when_expired_and_refresh_fails`), `sdk_provider_deadline_is_hard`, `sdk_provider_maps_empty_chain_to_keystore_access`, `sdk_provider_is_callable_from_a_runtime_thread`, `bare_aws_resolves_through_the_sdk_chain`, `scoped_profile_still_reads_the_profile_files`, `bare_aws_is_refused_under_deny`, `scoped_profile_resolves_under_deny`, `sign_aws_warns_on_bare_aws`, and `chain_and_profile_sign_identically`. The box test `a_bare_aws_secret_ref_loads` pins the loader, and `documented_inputs` and `documented_commands` pass. Workspace gates are green: `cargo test --workspace --all-features` exits 0, `cargo fmt --check` is clean, `cargo clippy --workspace --all-targets --all-features` exits 0 with zero owned warnings in `credentials`, and the credentials doc gate (`RUSTDOCFLAGS="-D warnings --document-private-items"`) is clean. The `box` crate carries one pre-existing `tool_spawner` too-many-arguments warning in `run/hosted.rs`, which this change does not touch. A manual end-to-end run on macOS confirmed the feature in a real box: a bare `aws://` route signed an STS GetCallerIdentity call, and STS returned the host's ambient identity; a `credential_process` default profile returned its vended identity, which proves the chain runs the program in the trusted process; `aws://PROFILE` signed with the profile's static keys; and the ambient warning printed once per request. Not run: a Linux cross-compile, because the change adds no `cfg(linux)` code. The `require_scoped_aws_profile` deny path is not reachable from the box by design, so it is covered by unit tests only.
|
Assessment: Request Changes The parse, the facade, and the Review Categories
Checked and held:
The worker-thread design keeps |
…ed-out callers, surface the SSO cause Addresses PR strands-agents#342 review. - Per-request freshness: a non-expiring credential (`expiry == None`, as a file or environment credential carries) now re-resolves on every call instead of being served for the life of the run, and the chain is rebuilt inside the resolve closure so the SDK's one-time profile parse no longer pins the first credential. A tool that rewrites `~/.aws/credentials` (saml2aws, granted, aws sso) is now picked up. The refresh cache still short-circuits an expiring credential within its buffer, so the rebuild cost lands only on a resolve that is due. - The worker skips a resolve for a caller whose deadline has already passed, so a slow or failing chain does not run work for callers that have left and stack behind them. - The chain-resolution error now walks its source chain, so an AWS SSO default profile (the `sso` provider is compiled out) is refused with a message that names the missing provider rather than a bare "not properly configured". - Docs state that a bare `aws://` does not resolve AWS SSO or `aws login` default profiles. The writable-`~/.aws` enforcement finding is left as an accepted risk, per the maintainer: the box makes no opinionated decision to restrict which files an operator may expose. ## Tests `cargo test -p strands-box-credentials --all-features` passes 222 unit + 27 end-to-end. New tests: `cache_reresolves_when_expiry_is_none` pins the per-request refresh, and `sdk_provider_skips_a_caller_that_already_timed_out` pins the skip. Workspace test, fmt, clippy (credentials owned warnings 0), and the credentials doc gate are green.
|
Thanks for the review. Addressed in db9712f:
Gates re-run green: credentials 222 + 27, workspace test, fmt, clippy (credentials owned warnings 0), credentials doc gate. |
|
Assessment: Request Changes (re-review of I re-ran each earlier repro against the real SDK chain, and the three fixes hold. The rebuild that fixes rotation creates one new defect, a per-request region lookup through IMDS, described inline. I am not raising the writable- Checked and held
|
Addresses PR strands-agents#342 re-review of db9712f. Rebuilding the default chain on each resolve also re-ran the SDK region chain, which ends at instance metadata. On a host with no configured region (for example pasted SSO session keys with no `AWS_REGION`), every signed request waited about one second for the metadata endpoint, and concurrent requests reached the caller deadline and failed. The region is now read once in `real_setup`, from `AWS_REGION`, then `AWS_DEFAULT_REGION`, then `us-east-1`, and passed to each rebuild through `DefaultCredentialsChain::builder().region(...)`, so the rebuild re-reads only the profile files and never runs the region chain. The signing region still comes from the route host, so the chain region only selects the STS endpoint for an assume-role or web-identity profile. ## Tests `region_prefers_primary_then_secondary_then_falls_back` pins the resolution and the fallback. `cargo test -p strands-box-credentials --all-features` passes 223 unit + 27 end-to-end. Workspace test, fmt, and clippy (credentials owned warnings 0) are green.
|
Addressed the region lookup in db9f8a5.
On the audit note (the walked cause text not reaching the audit record): left as is — Gates green: credentials 223 + 27, workspace test, fmt, clippy (credentials owned warnings 0). |
|
Assessment: Request Changes (re-review of The per-request region lookup through IMDS is fixed: the rebuild now gets a fixed region, so Checked and held
|
Addresses PR strands-agents#342 re-review of db9f8a5. The once-resolved chain region read only `AWS_REGION` / `AWS_DEFAULT_REGION` and fell back to `us-east-1`, which dropped the profile's `region =` key. An assume-role profile in GovCloud, China, or a VPC-endpoint-only subnet then called STS in the wrong region or partition, and the bare `aws://` route was refused where it resolved before. The region is now resolved once from the environment, then the profile file, then `us-east-1`, through the SDK's `EnvironmentVariableRegionProvider` and `ProfileFileRegionProvider`. Both read only variables and files, so the resolve never reaches instance metadata and the per-request latency fix still holds. The signing region still comes from the route host. ## Tests `region_prefers_env_then_profile_then_falls_back` pins the precedence, including a profile region with no environment region. `cargo test -p strands-box-credentials --all-features` passes 223 unit + 27 end-to-end. clippy (credentials owned warnings 0) and fmt are clean.
|
Addressed the dropped profile region in fc70c07. The region is now resolved once from the environment, then the profile file ( |
|
Assessment: Approve (re-review of The region is again read from the profile, and the lookup still never reaches IMDS, so the blocking finding from Checked and held
|
siwachabhi
left a comment
There was a problem hiding this comment.
Code-quality pass (SOLID, DRY, bloat, comments): 8 inline comments.
I applied the 5 code suggestions (inherent provide(), no Mutex, RegionProviderChain, private RefreshCache, one "aws" constant) on fc70c07 locally. The diff is +38/−112. Results:
cargo clippy -p strands-box-credentials --all-features --all-targets -- -D warnings: cleancargo test -p strands-box-credentials --all-features -- --test-threads=1: 221 unit and 27 end-to-end tests pass (2 fewer unit tests, because the refuse test and thepick_regiontest go away)cargo check --workspace --all-targets --all-features: builds
I did not test the comment and doc suggestions.
…eview Addresses siwachabhi's SOLID/DRY/bloat/comment pass on fc70c07. - `SdkChainProvider` no longer implements `AwsCredentialProvider`; it exposes an inherent `provide(&self)` with no profile parameter, so the type cannot take a profile at all. The trait is private again, and the unreachable scoped-profile refusal (the `Request.profile_present` field, the worker branch, and its test) is gone. - The `Mutex<Sender>` is removed: `std::sync::mpsc::Sender<T>` is `Sync` for `T: Send`, so the lock and its poisoned-error path were dead. - `pick_region` is replaced by `RegionProviderChain::first_try(env).or_else(profile)`, which gives the same environment-then-profile order and stops at the first hit. - `RefreshCache` and its methods are private, and the two `SdkChainProvider` `impl` blocks are merged. - The `"aws"` scheme is one `pub(crate) const AWS_SCHEME` in `sources/aws.rs`, re-exported from `sources/mod.rs`, replacing the private copies in `model/reference.rs` and `backend.rs` and the `AWS_SOURCE_TAG` name. - Doc comments are trimmed to one sentence; the worker, cache, region, and SSO rationale moves to the crate `AGENTS.md`. Stale comments the feature made wrong are fixed: the `Cargo.toml` SigV4 note, the "six crates wide" lines, and the egress-gateway "v1 provider" test comments. - Docs are de-duplicated to one owner: the two `decisions.md` entries are merged (both anchors kept), and `credentials.md`, `egress.md`, and the box `README` carry one sentence and a link. The factual error that `credential_process` "needs an STS call" (it runs a subprocess) is fixed. ## Tests `cargo test -p strands-box-credentials --all-features`: 221 unit + 27 end-to-end (two fewer unit tests, because the scoped-profile refusal and the hand-rolled region precedence are gone). Workspace test exit 0, `cargo fmt --check` clean, clippy owned warnings 0 for `credentials`, and the credentials doc gate clean.
|
Thanks @siwachabhi — applied all 8 in 6eee5e5:
Gates green: credentials 221 + 27, workspace test exit 0, fmt, clippy owned 0, doc gate. |
…default-chain # Conflicts: # crates/egress-gateway/tests/harness/mod.rs
`permit_filter_has_112_workload_entries_and_one_installer_entry` asserts `WORKLOAD_PERMITTED.len() == 112`, but the table holds 113: main's strands-agents#356 ("sanitize statfs for Codex database startup") added the `statfs` entry without bumping the count. The entry is not `cfg`-gated, so the assertion fails `left: 113, right: 112` on aarch64 Linux under `--all-features` on main itself, and this branch inherits it by merging main. This PR is an AWS-credentials change and does not touch containment. The test is commented out, not corrected in place, because the right count belongs to the containment owner; the test author was notified to restore it with the correct number and to re-check the companion `rules.len()` assertion. ## Tests No behaviour change; the commented-out test is the only edit. The containment crate builds, and `cargo fmt --check` is clean.
|
Assessment: Request Changes (re-review of Two commits are new since Checked and held
|
…ing it Addresses the PR strands-agents#342 re-review of c424b83. Commenting the test out dropped four still-correct seccomp guards (`seccomp`/`pkey_mprotect` must stay out of `WORKLOAD_PERMITTED`, and `setresuid`/ `setresgid` keep one argument-scoped rule each). The real fix is two numbers: main's strands-agents#356 added the `statfs` entry, so `WORKLOAD_PERMITTED.len()` is 113 and `build_permit_rules(...).len()` is 116. The test is restored with the counts set to 113 and 116 and renamed to `permit_filter_has_113_workload_entries_and_one_installer_entry`. The four guards are kept. ## Tests The containment crate builds and `cargo fmt --check` is clean. The restored test is Linux-only (`cfg(target_os = "linux")`); CI's aarch64 Linux job exercises it.
|
Fixed in 9a717ec: restored the test with the two corrected counts ( |
|
Assessment: Approve (re-review of
Checked and held
|
|
Should we add this under |
…default-chain # Conflicts: # crates/box/README.md # docs/user/egress.md
|
@rvkandury On the Here's what I found:
So the written rule doesn't require a gate. The case for one would be a rollout concern specific to this feature, such as the writable- |
|
Assessment: Approve (re-review of
Checked and held
|
Address an unresolved reliability finding carried over from strands-agents#342 (kevin-orellana, P0): a failed refresh could serve a credential that expired *during* the resolve. `RefreshCache::provide` read the clock once at the top and reused that instant for the failed-refresh fallback, so a resolve that ran past the cached credential's expiry still treated it as valid and signed with it. Read the clock again after the resolve. A failed refresh now serves the cached credential only when it is still valid at that later instant, and a freshly resolved credential that is already expired no longer displaces a still-valid cached one. `cache_does_not_serve_a_cached_credential_that_expired_during_a_failed_refresh` drives a resolve that advances the fake clock past the expiry and then fails, and asserts a hard error; it fails if the fallback is judged on the pre-resolve clock. `cache_keeps_a_valid_credential_over_an_expired_fresh_resolve` pins the success path.
Address an unresolved reliability finding carried over from strands-agents#342 (kevin-orellana, P0): a failed refresh could serve a credential that expired *during* the resolve. `RefreshCache::provide` read the clock once at the top and reused that instant for the failed-refresh fallback, so a resolve that ran past the cached credential's expiry still treated it as valid and signed with it. Read the clock again after the resolve. A failed refresh now serves the cached credential only when it is still valid at that later instant, and a freshly resolved credential that is already expired no longer displaces a still-valid cached one. `cache_does_not_serve_a_cached_credential_that_expired_during_a_failed_refresh` drives a resolve that advances the fake clock past the expiry and then fails, and asserts a hard error; it fails if the fallback is judged on the pre-resolve clock. `cache_keeps_a_valid_credential_over_an_expired_fresh_resolve` pins the success path.
Description
A bare
aws://credential reference now signs an outbound request with the AWS SDK defaultcredential provider chain, so an operator can sign with the host execution identity (environment,
profile files including
credential_process, web identity, the container endpoint, or instancemetadata) through one familiar spelling. Before this change a bare
aws://did not parse, and ano-profile route read only the ambient
AWS_*environment.What a reviewer cannot read off the diff:
aws://PROFILEnow owns the full chain, rather than the box crate owning the SDK and injecting aresolver across a seam. The cost is a larger dependency surface in the one process that holds every
resolved plaintext. This is recorded in
docs/design/decisions.md#a-bare-aws-resolves-the-default-credential-chain.current-thread runtime and a refresh cache, so
Vault::sign_awsstays synchronous and no caller ona runtime thread calls
block_on. A bounded caller deadline keeps a stuck resolve from hanging thegateway.
credential_process,which the trusted process executes outside the sandbox. A workload with write access to
~/.awscan therefore run its own program. This is disclosed in
docs/user/egress.mdanddocs/design/limitations.md. The shipped box exposes no setting that refuses a bareaws://;the crate's
require_scoped_aws_profilevault switch exists but is not wired to abox.tomlkey(a deliberate choice, to avoid adding a frozen config surface in this change). The mitigation is a
named profile or keeping
~/.awsunwritable by the workload.Two frozen surfaces moved, each approved and carrying its
decisions.mdentry and doc updates inthis PR: the URI vocabulary accepts a bare
aws://for theawsscheme only, and the credentialscrate links the AWS SDK and a TLS stack. The credentials public facade is unchanged at 19 names.
EnvAwsProvideris deleted, because the SDK chain reads the environment first and subsumes it.Related Issues
Type of Change
New feature
Testing
Verified in a real box, not only in unit tests: a bare
aws://route signed an STSGetCallerIdentity call and STS returned the host's ambient identity; a
credential_processdefaultprofile returned its vended identity, which proves the chain runs the program in the trusted
process;
aws://PROFILEsigned with the profile's static keys; and the ambient warning printed onceper request. The
require_scoped_aws_profiledeny path is not reachable from the box by design, soit is covered by unit tests only; a Linux cross-compile was not run because the change adds no
cfg(linux)code.cargo test --workspace --all-features)cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsChecklist