Harden agent attack surface: scan writes to memory, skills, cron, and context files
The security scanner (skills_guard.py) was only wired into the hub install path. All other write paths to persistent state — skills created by the agent, memory entries, cron prompts, and context files — bypassed it entirely. This closes those gaps: - file_operations: deny-list blocks writes to ~/.ssh, ~/.aws, ~/.hermes/.env, etc. - code_execution_tool: filter secret env vars from sandbox child process - skill_manager_tool: wire scan_skill() into create/edit/patch/write_file with rollback - skills_guard: add "agent-created" trust level (same policy as community) - memory_tool: scan content for injection/exfil before system prompt injection - prompt_builder: scan AGENTS.md, .cursorrules, SOUL.md for prompt injection - cronjob_tools: scan cron prompts for critical threats before scheduling Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -381,7 +381,14 @@ def execute_code(
|
||||
rpc_thread.start()
|
||||
|
||||
# --- Spawn child process ---
|
||||
child_env = os.environ.copy()
|
||||
# Filter out secret env vars to prevent exfiltration from sandbox
|
||||
_SECRET_PATTERNS = ("KEY", "TOKEN", "SECRET", "PASSWORD", "CREDENTIAL",
|
||||
"API_KEY", "OPENROUTER", "ANTHROPIC", "OPENAI",
|
||||
"AWS_SECRET", "GITHUB_TOKEN")
|
||||
child_env = {
|
||||
k: v for k, v in os.environ.items()
|
||||
if not any(pat in k.upper() for pat in _SECRET_PATTERNS)
|
||||
}
|
||||
child_env["HERMES_RPC_SOCKET"] = sock_path
|
||||
child_env["PYTHONDONTWRITEBYTECODE"] = "1"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user