mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
Fix: #41
This commit is contained in:
@@ -381,7 +381,20 @@ def execute_code(
|
|||||||
rpc_thread.start()
|
rpc_thread.start()
|
||||||
|
|
||||||
# --- Spawn child process ---
|
# --- Spawn child process ---
|
||||||
child_env = os.environ.copy()
|
# Build a minimal environment for the child. We intentionally exclude
|
||||||
|
# API keys and tokens to prevent credential exfiltration from LLM-
|
||||||
|
# generated scripts. The child accesses tools via RPC, not direct API.
|
||||||
|
_SAFE_ENV_PREFIXES = ("PATH", "HOME", "USER", "LANG", "LC_", "TERM",
|
||||||
|
"TMPDIR", "TMP", "TEMP", "SHELL", "LOGNAME",
|
||||||
|
"XDG_", "PYTHONPATH", "VIRTUAL_ENV", "CONDA")
|
||||||
|
_SECRET_SUBSTRINGS = ("KEY", "TOKEN", "SECRET", "PASSWORD", "CREDENTIAL",
|
||||||
|
"PASSWD", "AUTH")
|
||||||
|
child_env = {}
|
||||||
|
for k, v in os.environ.items():
|
||||||
|
if any(s in k.upper() for s in _SECRET_SUBSTRINGS):
|
||||||
|
continue
|
||||||
|
if any(k.startswith(p) for p in _SAFE_ENV_PREFIXES):
|
||||||
|
child_env[k] = v
|
||||||
child_env["HERMES_RPC_SOCKET"] = sock_path
|
child_env["HERMES_RPC_SOCKET"] = sock_path
|
||||||
child_env["PYTHONDONTWRITEBYTECODE"] = "1"
|
child_env["PYTHONDONTWRITEBYTECODE"] = "1"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user