Skip to content

feat: profile boundary isolation for cross-profile data protection#9960

Open
whyihaveyou wants to merge 1 commit into
NousResearch:mainfrom
whyihaveyou:feat/profile-boundary-isolation
Open

feat: profile boundary isolation for cross-profile data protection#9960
whyihaveyou wants to merge 1 commit into
NousResearch:mainfrom
whyihaveyou:feat/profile-boundary-isolation

Conversation

@whyihaveyou

Copy link
Copy Markdown

Summary

Add is_within_profile_boundary() guard to file tool operations to prevent named profiles from accessing other profiles' data directories (memory, sessions, config).

Problem

In multi-profile setups (e.g., separate Feishu bots per profile), all profiles share the same Python venv and codebase. Without boundary enforcement, one profile's agent could accidentally — or via LLM hallucination — read or modify another profile's memory, sessions, or configuration.

This was discovered after a real incident where a frog profile agent rebuilt the shared venv, breaking TLS for all profiles simultaneously.

Changes

File Description
hermes_constants.py Add is_profiled_mode(), get_profile_boundary(), is_within_profile_boundary() — soft isolation that blocks cross-profile access while preserving full filesystem access for project work
tools/file_tools.py Add boundary checks at all four file operation entry points (read_file, write_file, patch, search)
tests/test_profile_boundary.py 28 tests covering default profile (admin, unrestricted), named profiles (restricted), symlinks, tilde expansion, edge cases

Design Decisions

  • Soft isolation, not sandbox: Named profiles still need to read/write project code, system configs, and installed tools. The guard only blocks access to ~/.hermes/profiles/OTHER_PROFILE/.
  • Default profile is admin: The default profile (HERMES_HOME == ~/.hermes) has no restrictions — it needs access to all profiles for management tasks (profile list, skill syncing, etc.).
  • LLM-level only (for now): The guard applies to file_tools.py (the LLM's file interface). Terminal and execute_code can still bypass via cat/open(). A future PR could extend this to approval.py patterns.

Known Limitations

  • Does not cover terminal_tool.py or code_execution_tool.py — those can still access arbitrary paths via shell commands. Suggested follow-up: add dangerous path patterns to approval.py.
  • Venv sharing is the remaining blast radius — this PR addresses data isolation, not dependency isolation.

Test Plan

  • 28 new tests all pass
  • Existing test suite passes on this branch
  • Tested in production with two profiles (default + frog) on macOS

Add is_within_profile_boundary() guard to file tool operations
(read, write, patch, search) to prevent named profiles from accessing
other profiles' data directories (memory, sessions, config).

- hermes_constants.py: add is_profiled_mode(), get_profile_boundary(),
  is_within_profile_boundary() — soft isolation that blocks cross-profile
  access while preserving full filesystem access for project work
- tools/file_tools.py: add boundary checks at all four file operation
  entry points (read, write, patch, search)
- tests/test_profile_boundary.py: 28 tests covering default profile
  (admin, unrestricted), named profiles (restricted), symlinks,
  tilde expansion, edge cases

Motivation: In multi-profile setups (e.g., separate Feishu bots per
profile), profiles share the same Python venv and codebase. Without
boundary enforcement, one profile's agent could accidentally read or
modify another profile's memory, sessions, or configuration.
@alt-glitch alt-glitch added type/security Security vulnerability or hardening P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder tool/file File tools (read, write, patch, search) labels Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists tool/file File tools (read, write, patch, search) type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants