fix(security): strip Bedrock inference bearer token from subprocess env (#32314) - #34498
Merged
Conversation
…ken only Scopes the AWS_SDK subprocess strip down from the full AWS credential chain to just AWS_BEARER_TOKEN_BEDROCK — the only Hermes-managed *inference* secret (analogous to OPENAI_API_KEY). The general AWS credential chain (AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN / AWS_PROFILE / config + role pointers) is intentionally left inheritable. Why: per SECURITY.md §3.2 the local terminal is the user's trusted operator shell. Hard-blocklisting the general chain would (a) regress *every* user who runs aws/terraform/cdk/boto3 in the agent terminal — not just Bedrock users, since PROVIDER_REGISTRY is iterated unconditionally at import — and (b) be unrecoverable, because env_passthrough.py refuses to re-allow anything in _HERMES_PROVIDER_ENV_BLOCKLIST (GHSA-rhgp-j443-p4rf). The narrow strip closes the reported leak (opencode enumerating the Bedrock catalog off the leaked bearer token) with no capability loss. Keeps zapabob's self-healing auth_type=="aws_sdk" mechanism so any future SDK-cred provider is covered automatically. Tests: bearer token stripped + general chain preserved (no-regression guard), on both the runtime strip path and the blocklist-membership path. Co-authored-by: zapabob <1920071390@campus.ouj.ac.jp>
Contributor
🔎 Lint report:
|
This was referenced May 29, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug (confirmed live on main)
bedrock'sProviderConfigdeclaresapi_key_env_vars=()because it usesauth_type="aws_sdk"(boto3 credential chain)._build_provider_env_blocklist()only consults
api_key_env_vars, and there were zeroAWS_*entries in thehardcoded set. Net effect: every other provider's key is stripped from
terminal/execute_codesubprocess env, but a Bedrock user'sAWS_BEARER_TOKEN_BEDROCKleaked into every child process — the reportercaught it when
opencode modelsrun inside a Hermes terminal enumerated theentire Bedrock catalog off the leaked bearer token.
Closes #32314.
The fix — narrow, no capability regression
Strip only
AWS_BEARER_TOKEN_BEDROCK, the Bedrock-specific Hermesinference secret (exactly analogous to
OPENAI_API_KEY). The strip is keyedoff
auth_type=="aws_sdk", so it is self-healing — any future SDK-credprovider is covered automatically without editing a list.
The general AWS credential chain (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_SESSION_TOKEN,AWS_PROFILE, region/config/role pointers) isintentionally left inheritable. Per SECURITY.md §3.2 the local terminal is
the user's trusted operator shell; the agent having the same general AWS access
the user's own shell has is the intended posture.
Hard-blocklisting the full chain (as the original PRs in this cluster did) would:
PROVIDER_REGISTRYisiterated unconditionally at import, so the
aws_sdkbranch fires foreveryone. A pure-OpenAI user running
aws s3 cp/terraform apply/ aboto3script in the agent terminal would lose their creds for no securitybenefit.
tools/env_passthrough.pyrefuses to re-allowanything in
_HERMES_PROVIDER_ENV_BLOCKLIST(GHSA-rhgp-j443-p4rf), so thereis no config or skill escape hatch. Capability gone, permanently.
Verification
Live E2E (real bash subprocess via
LocalEnvironment.execute(), AWS varsactually in
os.environ— not mocked):Tests (
tests/tools/test_local_env_blocklist.py, all 22 pass):test_bedrock_bearer_token_is_stripped— the [Bug]: auth_type="aws_sdk" never feeds into subprocess credential blocklist; AWS env vars leak to terminal/execute_code #32314 leak is closedtest_general_aws_credential_chain_is_preserved— no-regression guardtest_bedrock_bearer_token_is_in_blocklisttest_general_aws_chain_not_in_blocklist— no-regression guardSalvage / attribution
Built on @zapabob's #34387 (the self-healing
auth_type=="aws_sdk"mechanism),narrowed to bearer-token-only. Supersedes #34387, #32319 (@briandevans),
#32402 (@leavedrop), #32374 (@HiddenPuppy) — all four implemented the same
fix but hard-blocklisted the full AWS chain, which trips the regression above.
Co-authored-by: zapabob 1920071390@campus.ouj.ac.jp