feat: profile boundary isolation for cross-profile data protection - #9960
Open
whyihaveyou wants to merge 1 commit into
Open
feat: profile boundary isolation for cross-profile data protection#9960whyihaveyou wants to merge 1 commit into
whyihaveyou wants to merge 1 commit into
Conversation
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.
teknium1
reviewed
Jul 12, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the profile-isolation work. Current main has since merged a narrower soft cross-profile write guard in #31290 (d3c167b64472ee35e52d5201014e940c965579ef), but this patch needs substantial re-scoping before it can be salvaged.
Problems
tools/file_tools.py:583only checks the explicitpath; normal V4Amode="patch"calls provide targets in patch headers withpath=None, so this guard does not inspect them. Current main extracts and checks V4A targets attools/file_tools.py:1731-1783.- The new
is_profiled_mode()reads rawHERMES_HOME, bypassing the context-local profile override supported by currenthermes_constants.py:23-77. - The proposal hard-blocks cross-profile reads/searches across an entire profile. Current main intentionally permits explicit read-only cross-profile session access via
tools/session_search_tool.py:631-675; the broader policy needs an explicit threat-model decision.
Suggested changes
- Build any follow-up on the current
agent/file_safety.pyclassifier and its scoped soft-guard/explicit-consent model. - Cover V4A targets, task-relative paths, and context-local profile resolution.
Automated hermes-sweeper review.
| # ── Profile boundary guard ──────────────────────────────────── | ||
| # Check explicit path first, then extract paths from V4A patch content | ||
| _paths_to_check = [] | ||
| if path: |
Contributor
There was a problem hiding this comment.
For mode="patch", callers normally omit path, so this list remains empty and the *** Update File: target is never boundary-checked. Extract every V4A Update/Add/Delete/Move target before this loop; current main's equivalent handling is at tools/file_tools.py:1731-1783.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
hermes_constants.pyis_profiled_mode(),get_profile_boundary(),is_within_profile_boundary()— soft isolation that blocks cross-profile access while preserving full filesystem access for project worktools/file_tools.pyread_file,write_file,patch,search)tests/test_profile_boundary.pyDesign Decisions
~/.hermes/profiles/OTHER_PROFILE/.HERMES_HOME == ~/.hermes) has no restrictions — it needs access to all profiles for management tasks (profile list, skill syncing, etc.).file_tools.py(the LLM's file interface). Terminal andexecute_codecan still bypass viacat/open(). A future PR could extend this toapproval.pypatterns.Known Limitations
terminal_tool.pyorcode_execution_tool.py— those can still access arbitrary paths via shell commands. Suggested follow-up: add dangerous path patterns toapproval.py.Test Plan