Skip to content

fix(context): block @ references from reading secrets outside the workspace#2601

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
Gutslabs:fix/context-reference-sensitive-paths
Mar 23, 2026
Merged

fix(context): block @ references from reading secrets outside the workspace#2601
teknium1 merged 1 commit intoNousResearch:mainfrom
Gutslabs:fix/context-reference-sensitive-paths

Conversation

@Gutslabs
Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes a safety bug in @ context reference expansion.

Previously, CLI @file: / @folder: expansion defaulted to an unrestricted root, so absolute paths outside the current workspace could be attached directly into the prompt. Gateway expansion also allowed references to sensitive paths under the messaging working directory, including files like .hermes/.env and .ssh/id_rsa.

This change makes @ references default to the current working directory boundary and blocks known sensitive credential / internal Hermes paths even when they are technically inside the allowed root.

Type of Change

  • Bug fix
  • Security fix
  • Tests

Changes Made

  • Default allowed_root to cwd when expanding @file: and @folder: references
  • Reject sensitive credential paths under $HOME such as .ssh/*, shell rc files, and similar secret-bearing files
  • Reject internal Hermes paths such as $HERMES_HOME/.env and $HERMES_HOME/skills/.hub/...
  • Added regression tests for workspace escape and sensitive path blocking

How to Test

  1. Run source .venv/bin/activate
  2. Run pytest -q tests/test_context_references.py
  3. Confirm @file:/absolute/path/outside/workspace is refused by default
  4. Confirm @file:.hermes/.env and @file:.ssh/id_rsa are blocked even when they are under the allowed root

Validation

  • pytest -q tests/test_context_references.py -> 11 passed
  • Direct repro before the fix allowed secret content from .hermes/.env and .ssh/id_rsa to be injected into the prompt
@teknium1 teknium1 merged commit 2d8fad8 into NousResearch:main Mar 23, 2026
1 check passed
InB4DevOps pushed a commit to InB4DevOps/hermes-agent that referenced this pull request Mar 24, 2026
…arch#2601)

fix(context): block @ references from reading secrets outside the workspace. Defaults allowed_root to cwd, adds sensitive file blocklist.
InB4DevOps pushed a commit to InB4DevOps/hermes-agent that referenced this pull request Mar 24, 2026
…arch#2601)

fix(context): block @ references from reading secrets outside the workspace. Defaults allowed_root to cwd, adds sensitive file blocklist.
InB4DevOps pushed a commit to InB4DevOps/hermes-agent that referenced this pull request Mar 24, 2026
…arch#2601)

fix(context): block @ references from reading secrets outside the workspace. Defaults allowed_root to cwd, adds sensitive file blocklist.
InB4DevOps pushed a commit to InB4DevOps/hermes-agent that referenced this pull request Mar 25, 2026
…arch#2601)

fix(context): block @ references from reading secrets outside the workspace. Defaults allowed_root to cwd, adds sensitive file blocklist.
outsourc-e pushed a commit to outsourc-e/hermes-agent that referenced this pull request Mar 26, 2026
…arch#2601)

fix(context): block @ references from reading secrets outside the workspace. Defaults allowed_root to cwd, adds sensitive file blocklist.
aashizpoudel pushed a commit to aashizpoudel/hermes-agent that referenced this pull request Mar 30, 2026
…arch#2601)

fix(context): block @ references from reading secrets outside the workspace. Defaults allowed_root to cwd, adds sensitive file blocklist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants