fix(security): scope passthrough env to routed profile - #76213
Merged
teknium1 merged 2 commits intoAug 2, 2026
Merged
Conversation
teknium1
reviewed
Aug 1, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for covering the local, background/PTY, execute_code, and Docker runtime paths; the current-main premise is real (tools/environments/local.py:1226-1237, tools/environments/docker.py:1523-1529).
Problems
tools/environments/docker.py:1591refreshes explicitdocker_forward_envvalues per command, buttools/environments/base.py:547-552excludes/restores onlyget_all_passthrough()names. An explicit forward-only key remains in the shared snapshot. The Docker unset is prepended beforeBaseEnvironment._wrap_command()sources that snapshot (tools/environments/base.py:720-752), so the prior profile's snapshot value can override the new-evalue or resurrect after unset.
Suggested changes
- Include validated
DockerEnvironment._forward_envnames in the profile-scoped snapshot exclusion set and add an execute-through-wrapper regression for explicit forward-only profile A → B → missing behavior.
Automated hermes-sweeper review.
Contributor
|
Merged — thanks @Christopher-Schulze. This was the reference implementation of the passthrough fix: centralized resolve_passthrough_value honoring get_secret's verdict across all four child-env paths, scope-change staleness handling, and real two-profile tests. It completes the wave that #76462/#76573 carried. |
1 task
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.
What does this PR do?
Under
gateway.multiplex_profiles, allowlisted environment variables were still read from the process environment in terminal andexecute_codechild processes. Because the process environment belongs to the default profile, a routed profile could silently run with another profile's valid credentials.This PR centralizes passthrough-value resolution through the active profile secret scope and applies it to execute_code, local foreground/background terminal paths, and Docker init/runtime paths. It also prevents persistent shell snapshots and reused containers from retaining a previous profile's value, while preserving single-profile fallback and global terminal overrides.
PR #76199 is the directly linked competing implementation. It only covers local foreground and Docker init forwarding; this PR is the user-authorized completion of the same issue, including execute_code, background/PTY, persistent snapshots, Docker runtime refresh/clearing, and the corresponding regression coverage.
Related Issue
Fixes #76163
Type of Change
Changes Made
resolve_passthrough_value()intools/env_passthrough.pyas the shared profile-aware resolver.tools/code_execution_tool.pyand both local terminal spawn paths to use the active scope, omit missing scoped values, and fail closed for unscoped multiplex reads.BaseEnvironmentsnapshots so profile-scoped names, including explicitdocker_forward_enventries, cannot persist across Local/Docker commands or profiles.How to Test
local='token-for-default'and DockerSERVICE_TOKEN=token-for-default.LocalEnvironmentproduced profile A's token, then profile B's token, thenunsetfor an empty profile, all with return code 0.scripts/run_tests.sh tests/tools/test_env_passthrough.py tests/tools/test_local_env_blocklist.py tests/tools/test_local_env_session_leak.py tests/tools/test_local_env_windows_msys.py tests/tools/test_docker_environment.py tests/tools/test_code_execution_windows_env.py tests/tools/test_execute_code_approval_cluster.py tests/agent/test_secret_scope.py tests/tools/test_tool_backend_helpers.py tests/gateway/test_multiplex_credential_isolation.py tests/gateway/test_api_server_multiplex_secret_scope.py tests/cron/test_run_one_job.pyResult: 12 files, 233 tests passed, 0 failed.
scripts/check.sh --project hermes-agent --worktree worktrees/hermes-agent/76163; all blocking gates pass.uv lock --check, Ruff, changed-file tests, Windows footgun scan, and policy verification are clean; ty has only the repository's pre-existing diagnostics/panic.Checklist
Code
fix(security): scope passthrough env to routed profile.Documentation & Housekeeping
cli-config.yaml.exampleupdate is not applicable.CONTRIBUTING.mdandAGENTS.mdupdate is not applicable.