Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

[feature] Hermes guard: in a tainted chat session, escalate privileged calls to Hermes' approval gate instead of refusing outright

Open IvanLeontev-stack opened this issue 1 week ago • 1 comments

What happens

Control 4 (provenance tainting, LIFEOS/HERMES/plugin/guard.py) is per-session and sticky. In the messaging gateway the session key is the chat session (gateway/run_turn_runner.py passes ctx.session_id, the turn context's session id, as task_id to run_conversation), and gateway sessions persist across inactivity and day boundaries. So one web_search early in a Telegram chat means every later privileged call in that chat (send, write_file, patch, execute_code, cron_create, and the privileged command globs) is refused until the user sends /new or /reset, even when the user asks for it directly several messages later.

In everyday phone use the main reason to message the sidecar is "look something up, then do something with it" (look up, then remind me / send / save). The hard refusal turns that into "look it up, /new, re-explain, then do it".

Why approval fits here

HermesSidecar.md § Provenance tainting says the shipped behaviour is "stricter than the spec above": a tainted session "doesn't prompt for approval on a privileged call, it refuses in code", because "a cron turn has no human to approve anything".

Hermes now has a plugin escalation path that covers exactly that case: a pre_tool_call hook may return {"action": "approve", "message": ..., "rule_key": ...}. Hermes routes it to tools/approval.py::request_tool_approval, the same human gate as dangerous shell commands. Per its docstring, cron honours approvals.cron_mode (default deny), and any other non-interactive context without an approval bridge fails closed. So with the shipped defaults unattended runs keep today's refusal, and a human in a chat gets a yes/no on the exact call. (Caveat: cron_mode: approve or approvals.mode: off would auto-approve the gate, and Mount.ts leaves those to the operator, so the guard may want to keep a hard block when it can tell the turn is unattended, or Mount.ts could pin cron_mode: deny.)

Proposal

In guard.evaluate, return a third verdict kind for the taint branch, and have plugin/__init__.py map it to "action": "approve":

  • Credential/path/deny-glob verdicts stay block (unchanged).
  • Taint verdict with zero injection shapes matched → approve, with a message naming the tool, its target (command text or path), and what tainted the session.
  • Taint verdict with one or more injection shapes matched → stays block.
  • rule_key includes a hash of the call's arguments, so a "session" or "always" answer covers only that exact call, never the tool as a whole ("always" lands in the permanent allowlist, so this matters).

Environment

LifeOS 8.761.0, Hermes sidecar mounted with Mount.ts, gateway on Telegram.

IvanLeontev-stack avatar Nov 26 '26 16:11 IvanLeontev-stack

[!NOTE] 🤖 Kai (AI assistant) responding on behalf of Daniel Miessler

Thanks for the careful work here. The Hermes sidecar was retired on 2026-11-01 and replaced by Relay, so this code path no longer exists in our tree. The next public release removes the sidecar files from existing installs. Until then, 8.761.0 installs that run Hermes are still exposed, so turning the sidecar off is the safe move.

Fix: 4f129e23b9

danielmiessler avatar Dec 01 '26 08:12 danielmiessler