mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 01:21:43 +00:00
fix(env_passthrough): reject Hermes provider credentials from skill passthrough (#13523)
A skill declaring `required_environment_variables: [ANTHROPIC_TOKEN]` in its SKILL.md frontmatter silently bypassed the `execute_code` sandbox's credential-scrubbing guarantee. `register_env_passthrough` had no blocklist, so any name a skill chose flipped `is_env_passthrough(name) => True`, which shortcircuits the sandbox's secret filter. Fix: reject registration when the name appears in `_HERMES_PROVIDER_ENV_BLOCKLIST` (the canonical list of Hermes-managed credentials — provider keys, gateway tokens, etc.). Log a warning naming GHSA-rhgp-j443-p4rf so operators see the rejection in logs. Non-Hermes third-party API keys (TENOR_API_KEY for gif-search, NOTION_TOKEN for notion skills, etc.) remain legitimately registerable — they were never in the sandbox scrub list in the first place. Tests: 16 -> 17 passing. Two old tests that documented the bypass (`test_passthrough_allows_blocklisted_var`, `test_make_run_env_passthrough`) are rewritten to assert the new fail-closed behavior. New `test_non_hermes_api_key_still_registerable` locks in that legitimate third-party keys are unaffected. Reported in GHSA-rhgp-j443-p4rf by @q1uf3ng. Hardening; not CVE-worthy on its own per the decision matrix (attacker must already have operator consent to install a malicious skill).
This commit is contained in:
parent
7fc1e91811
commit
ba4357d13b
2 changed files with 92 additions and 17 deletions
|
|
@ -44,16 +44,59 @@ def _get_allowed() -> set[str]:
|
|||
_config_passthrough: frozenset[str] | None = None
|
||||
|
||||
|
||||
def _is_hermes_provider_credential(name: str) -> bool:
|
||||
"""True if ``name`` is a Hermes-managed provider credential (API key,
|
||||
token, or similar) per ``_HERMES_PROVIDER_ENV_BLOCKLIST``.
|
||||
|
||||
Skill-declared ``required_environment_variables`` frontmatter must
|
||||
not be able to override this list — that was the bypass in
|
||||
GHSA-rhgp-j443-p4rf where a malicious skill registered
|
||||
``ANTHROPIC_TOKEN`` / ``OPENAI_API_KEY`` as passthrough and received
|
||||
the credential in the ``execute_code`` child process, defeating the
|
||||
sandbox's scrubbing guarantee.
|
||||
|
||||
Non-Hermes API keys (TENOR_API_KEY, NOTION_TOKEN, etc.) are NOT
|
||||
in the blocklist and remain legitimately registerable — skills that
|
||||
wrap third-party APIs still work.
|
||||
"""
|
||||
try:
|
||||
from tools.environments.local import _HERMES_PROVIDER_ENV_BLOCKLIST
|
||||
except Exception:
|
||||
return False
|
||||
return name in _HERMES_PROVIDER_ENV_BLOCKLIST
|
||||
|
||||
|
||||
def register_env_passthrough(var_names: Iterable[str]) -> None:
|
||||
"""Register environment variable names as allowed in sandboxed environments.
|
||||
|
||||
Typically called when a skill declares ``required_environment_variables``.
|
||||
|
||||
Variables that are Hermes-managed provider credentials (from
|
||||
``_HERMES_PROVIDER_ENV_BLOCKLIST``) are rejected here to preserve
|
||||
the ``execute_code`` sandbox's credential-scrubbing guarantee per
|
||||
GHSA-rhgp-j443-p4rf. A skill that needs to talk to a Hermes-managed
|
||||
provider should do so via the agent's main-process tools (web_search,
|
||||
web_extract, etc.) where the credential remains safely in the main
|
||||
process.
|
||||
|
||||
Non-Hermes third-party API keys (TENOR_API_KEY, NOTION_TOKEN, etc.)
|
||||
pass through normally — they were never in the sandbox scrub list.
|
||||
"""
|
||||
for name in var_names:
|
||||
name = name.strip()
|
||||
if name:
|
||||
_get_allowed().add(name)
|
||||
logger.debug("env passthrough: registered %s", name)
|
||||
if not name:
|
||||
continue
|
||||
if _is_hermes_provider_credential(name):
|
||||
logger.warning(
|
||||
"env passthrough: refusing to register Hermes provider "
|
||||
"credential %r (blocked by _HERMES_PROVIDER_ENV_BLOCKLIST). "
|
||||
"Skills must not override the execute_code sandbox's "
|
||||
"credential scrubbing; see GHSA-rhgp-j443-p4rf.",
|
||||
name,
|
||||
)
|
||||
continue
|
||||
_get_allowed().add(name)
|
||||
logger.debug("env passthrough: registered %s", name)
|
||||
|
||||
|
||||
def _load_config_passthrough() -> frozenset[str]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue