The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(terminal-env): a passthrough accepted before an adapter owned the name stops forwarding it
John Paul Soliva6abcf4d86aee
diff --git a/tests/tools/test_local_env_blocklist.py b/tests/tools/test_local_env_blocklist.pyindex 6b4229f6ae1..11e099f694a 100644--- a/tests/tools/test_local_env_blocklist.py+++ b/tests/tools/test_local_env_blocklist.py@@ -162,6 +162,44 @@ def test_runtime_adapter_secret_follows_the_bound_profiles_registry(child_env, massert child_sees() == {name: "fake-secret", "MY_APP_KEY": "operator"}[email protected]("declared_by", ["skill", "config"])+def test_passthrough_accepted_before_an_adapter_owns_the_name_stops_forwarding_it(+ child_env, monkeypatch, declared_by):+ from agent import secret_scope as ss+ from gateway.platform_registry import PlatformEntry, platform_registry+ from tools.code_execution_env import _scrub_child_env+ from tools.env_passthrough import register_env_passthrough+ name, names = "ACME_CHAT_SIGNING_SECRET", ["ACME_CHAT_SIGNING_SECRET", "MY_APP_KEY"]+ monkeypatch.setenv(name, "fake-secret")+ monkeypatch.setenv("MY_APP_KEY", "operator")+ if declared_by == "skill":+ register_env_passthrough(names)+ else:+ home = child_env / "hermes"+ home.mkdir(exist_ok=True)+ (home / "config.yaml").write_text("terminal:\n env_passthrough: [%s]\n" % ", ".join(names))+ builders = [lambda: local._make_run_env({}), lambda: local._sanitize_subprocess_env(dict(os.environ)),+ lambda: _scrub_child_env(dict(os.environ))]+ assert [observe_child(b(), names) for b in builders] == [+ {name: "fake-secret", "MY_APP_KEY": "operator"}] * 3 # accepted while operator-owned++ scope = platform_registry.current_scope_key()+ platform_registry.register(PlatformEntry(name="acme-chat", label="Acme", adapter_factory=lambda c: None,+ check_fn=lambda: True), scope=scope)+ try:+ assert [observe_child(b(), names) for b in builders] == [{name: None, "MY_APP_KEY": "operator"}] * 3+ # A routed profile's value lives only in its scope; the stale declaration must not add it back.+ monkeypatch.delenv(name)+ token = ss.set_secret_scope({name: "scoped-secret", "MY_APP_KEY": "scoped-operator"})+ try:+ assert [observe_child(b(), names) for b in (builders[0], builders[2])] == [+ {name: None, "MY_APP_KEY": "scoped-operator"}] * 2+ finally:+ ss.reset_secret_scope(token)+ finally:+ platform_registry.unregister("acme-chat", scope=scope)++@pytest.mark.parametrize("builder", ["foreground", "background", "factory", "nonterminal"])def test_builders_strip_runtime_markers_and_owned_paths(child_env, monkeypatch, builder):repo, site = Path(__file__).resolve().parents[2], _running_site()diff --git a/tools/env_passthrough.py b/tools/env_passthrough.pyindex ee8678c9827..8ae31650afc 100644--- a/tools/env_passthrough.py+++ b/tools/env_passthrough.py@@ -116,13 +116,19 @@ def _load_config_passthrough() -> frozenset[str]:def is_env_passthrough(var_name: str) -> bool:- """True if *var_name* was registered by a skill or listed in config."""- return var_name in _get_allowed() or var_name in _load_config_passthrough()+ """True if *var_name* was registered by a skill or listed in config and is not a+ Hermes-managed credential NOW. Ownership changes after acceptance (a plugin adapter+ registering later claims ``<PREFIX>_*_SECRET``), so the refusal applied at registration+ is re-applied here, where every child builder consumes the allowlist."""+ return ((var_name in _get_allowed() or var_name in _load_config_passthrough())+ and not _is_hermes_provider_credential(var_name))def get_all_passthrough() -> frozenset[str]:- """Return the union of skill-registered and config-based passthrough vars."""- return frozenset(_get_allowed()) | _load_config_passthrough()+ """Return the union of skill-registered and config-based passthrough vars, minus names+ that have become Hermes-managed credentials since they were accepted."""+ return frozenset(name for name in frozenset(_get_allowed()) | _load_config_passthrough()+ if not _is_hermes_provider_credential(name))def resolve_passthrough_value(name: str, fallback: str | None = None) -> str | None:diff --git a/website/docs/user-guide/security.md b/website/docs/user-guide/security.mdindex 72b52af6cae..f15a4cc4f30 100644--- a/website/docs/user-guide/security.md+++ b/website/docs/user-guide/security.md@@ -694,7 +694,7 @@ With the switch off Hermes never reads or refreshes those files: the `claude_cod- Credential files are mounted **read-only** into Docker containers- Skills Guard scans skill content for suspicious env access patterns before installation- Missing/unset vars are never registered (you can't leak what doesn't exist)-- Hermes infrastructure secrets (provider API keys, gateway tokens) should never be added to `env_passthrough` — they have dedicated mechanisms+- Hermes infrastructure secrets (provider API keys, gateway tokens) should never be added to `env_passthrough` — they have dedicated mechanisms. Such a name is refused when declared, and a declared name that a platform adapter claims later (a plugin adapter registering after the skill loaded) stops being forwarded from then on## MCP Credential Handlingdiff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/security.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/security.mdindex 2f47abfca10..bca848e50c7 100644--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/security.md+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/security.md@@ -441,7 +441,7 @@ terminal:- 凭据文件以**只读**方式挂载到 Docker 容器中- Skills Guard 在安装前会扫描技能内容中的可疑环境变量访问模式- 缺失/未设置的变量永远不会被注册(不存在的内容无法泄露)-- Hermes 基础设施密钥(提供商 API 密钥、gateway token)不应添加到 `env_passthrough`——它们有专用机制+- Hermes 基础设施密钥(提供商 API 密钥、gateway token)不应添加到 `env_passthrough`——它们有专用机制。声明此类名称时会被拒绝;已声明的名称若之后被某个平台适配器占用(例如在技能加载后才注册的插件适配器),从那时起便不再转发## MCP 凭据处理