Skip to content

security: harden dangerous command detection and add file tool path guards#3872

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-8e764fde
Mar 30, 2026
Merged

security: harden dangerous command detection and add file tool path guards#3872
teknium1 merged 1 commit intomainfrom
hermes/hermes-8e764fde

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Hardens dangerous command detection and adds file tool path guards. Closes gaps found in a security report where an agent exposed Docker's Remote API to the internet by writing tcp://0.0.0.0:2375 to /etc/docker/daemon.json.

What was vulnerable

Attack vector Before After
chmod 666 /var/run/docker.sock Not detected Blocked (approval prompt)
chmod o+rw /var/run/docker.sock Not detected Blocked
chmod a+w <any file> Not detected Blocked
sudo cp daemon.json /etc/docker/daemon.json Not detected Blocked
sudo mv /tmp/daemon.json /etc/docker/ Not detected Blocked
sudo sed -i 's/.../.../' /etc/docker/daemon.json Not detected Blocked
sudo install -m 644 file /etc/docker/ Not detected Blocked
write_file(path="/etc/docker/daemon.json", ...) No check Refused with error
patch(path="/etc/docker/daemon.json", ...) No check Refused with error

Already caught (no change needed): > /etc/..., tee /etc/..., cat > /etc/..., chmod 777

Changes

tools/approval.py:

  • chmod pattern widened: now catches 666, o+w, o+rw, a+w, a+rw (symbolic and numeric)
  • New patterns: cp/mv/install targeting /etc/, sed -i/--in-place targeting /etc/

tools/file_tools.py:

  • write_file and patch tools now check paths against sensitive prefixes (/etc/, /boot/, /usr/lib/systemd/) and exact paths (/run/docker.sock, /var/run/docker.sock) before writing
  • V4A multi-file patches extract all target paths from the patch header and check each one
  • Blocked writes return a clear error directing users to the terminal tool (which has approval prompts)

Tests

  • 121 existing approval + file_tools tests pass
  • Verified all 14 attack vectors blocked, 5 legitimate operations unaffected
…uards

Closes gaps that allowed an agent to expose Docker's Remote API to the
internet by writing to /etc/docker/daemon.json.

Terminal tool (approval.py):
- chmod: now catches 666 and symbolic modes (o+w, a+w), not just 777
- cp/mv/install: detected when targeting /etc/
- sed -i/--in-place: detected when targeting /etc/

File tools (file_tools.py):
- write_file and patch now refuse to write to sensitive system paths
  (/etc/, /boot/, /usr/lib/systemd/, docker.sock)
- Directs users to the terminal tool (which has approval prompts) for
  system file modifications
@teknium1 teknium1 merged commit 5602458 into main Mar 30, 2026
2 of 3 checks passed
itsXactlY pushed a commit to itsXactlY/hermes-agent that referenced this pull request Mar 30, 2026
…uards (NousResearch#3872)

Closes gaps that allowed an agent to expose Docker's Remote API to the
internet by writing to /etc/docker/daemon.json.

Terminal tool (approval.py):
- chmod: now catches 666 and symbolic modes (o+w, a+w), not just 777
- cp/mv/install: detected when targeting /etc/
- sed -i/--in-place: detected when targeting /etc/

File tools (file_tools.py):
- write_file and patch now refuse to write to sensitive system paths
  (/etc/, /boot/, /usr/lib/systemd/, docker.sock)
- Directs users to the terminal tool (which has approval prompts) for
  system file modifications
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant