fix(bedrock): register AWS credential env vars in subprocess credential blocklist - #32374
fix(bedrock): register AWS credential env vars in subprocess credential blocklist#32374HiddenPuppy wants to merge 2 commits into
Conversation
…al blocklist When the built-in bedrock provider uses auth_type="aws_sdk" (the default), AWS credential environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, etc.) were not registered in PROVIDER_REGISTRY.api_key_env_vars and therefore were never added to _HERMES_PROVIDER_ENV_BLOCKLIST. As a result, all agent-spawned terminal and code-execution subprocesses inherited AWS credentials that the agent did not intend to expose. Fix by adding the standard AWS SDK credential environment variables to the bedrock ProviderConfig's api_key_env_vars tuple. The blocklist builder in _build_provider_env_blocklist() already iterates all provider configs and picks up api_key_env_vars — the only gap was that bedrock's tuple was empty. Closes NousResearch#32314
|
Duplicate of #32319 — both fix #32314 (AWS credential env var leak on Bedrock). Note: #32319 covers 10 AWS vars (including container credential vars) and includes regression tests, while this PR covers 8 vars with no tests. The approaches are complementary (auth.py data fix vs local.py explicit blocklist) but #32319 is more comprehensive. |
- Update test_bedrock_integration.py: replace the assertion that api_key_env_vars == () with a positive check that AWS SDK env vars are now present (the fix deliberately adds them for subprocess credential blocklisting). - Add hiddenpuppy@users.noreply.github.com to scripts/release.py AUTHOR_MAP so the check-attribution CI passes for this contributor.
|
Superseded by #34498 (merged to main). Thanks for working #32314. Two reasons we went a different way: (1) stuffing AWS vars into |
Summary
This PR fixes a security issue where AWS credential environment variables leak to agent-spawned subprocesses (terminal, execute_code, MCP servers) when using AWS Bedrock as the inference provider.
Root Cause
In
hermes_cli/auth.py, the built-in BedrockProviderConfigis defined withapi_key_env_vars=()(empty tuple). The subprocess environment blocklist builder intools/environments/local.py(_build_provider_env_blocklist()) only consumesapi_key_env_varsfrom each provider config:Since bedrock's tuple was empty, none of the standard AWS SDK credential environment variables were ever added to
_HERMES_PROVIDER_ENV_BLOCKLIST, causing them to leak to all subprocesses.Impact
execute_code, MCP servers, agent delegations) silently inherit AWS credentialsopencode models) show Bedrock models inadvertentlyAWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYleak, subprocesses inherit all of the user's AWS capabilitiesFix
Add the standard AWS SDK credential environment variables to the Bedrock
ProviderConfig.api_key_env_vars:AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_SESSION_TOKENAWS_BEARER_TOKEN_BEDROCKAWS_PROFILEAWS_DEFAULT_REGIONAWS_ROLE_ARNAWS_WEB_IDENTITY_TOKEN_FILEThe
auth_type=\"aws_sdk\"field is already defined on the bedrock config; the blocklist builder already iterates all providers. The only gap was that no AWS credential env vars were listed.Closes #32314