Skip to content

fix(security): guard cron script against path traversal and redact output - #5147

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-db023341
Apr 5, 2026
Merged

teknium1 merged 1 commit into
mainfrom
hermes/hermes-db023341

Conversation

@teknium1

@teknium1 teknium1 commented Apr 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Salvage of PR #5093 by memosr (fixes 1 and 3; absolute path restriction dropped).

1. Path Traversal Guard (relative paths)

Relative script paths resolved against HERMES_HOME/scripts/ were not validated to stay within that directory. ../../etc/passwd would resolve outside and be executed as Python.

Fix: After resolving, verify the path stays within scripts_dir using Path.relative_to(). Paths that escape are rejected.

2. Secret Redaction

Script stdout was injected raw into the LLM prompt. If a script outputs env vars or API keys, they flow unmasked into context.

Fix: Apply redact_sensitive_text() to stdout before injection — same pattern as execute_code sandbox output.

What was dropped

The absolute path restriction to HERMES_HOME was dropped — it's too restrictive for the feature's design intent. Users may legitimately want to point cron scripts at paths outside ~/.hermes/. The agent already has full terminal access, so this doesn't close a meaningful security boundary.

Test plan

  • All 111 cron tests pass
  • E2E verified: legit scripts work, traversal blocked, absolute paths still allowed, secrets redacted

Credit: memosr (original PR #5093)

…tput

Relative script paths resolved against HERMES_HOME/scripts/ were not
validated to stay within that directory. Paths like '../../etc/passwd'
could escape and be executed as Python.

Fix: resolve the path and verify it stays within scripts_dir using
Path.relative_to(). Also apply redact_sensitive_text() to script stdout
before LLM injection — same pattern as execute_code sandbox output.

Cherry-picked from PR #5093 by memosr (fixes 1 and 3; absolute path
restriction dropped as too restrictive for the feature's design intent).
@teknium1
teknium1 merged commit 931624f into main Apr 5, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants