Skip to content

fix(gateway): replace bare text approval with /approve and /deny commands#2002

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-51eb4292
Mar 18, 2026
Merged

fix(gateway): replace bare text approval with /approve and /deny commands#2002
teknium1 merged 1 commit intomainfrom
hermes/hermes-51eb4292

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Fixes #1888. Replaces the fragile bare text-matching approval system in the gateway with explicit /approve and /deny slash commands.

The bug: The gateway intercepted bare yes/y/approve/ok text from the user's next message to approve dangerous commands. If the agent asked a clarify question (or moved on to other work) and the user said "yes" to answer it, the gateway would execute the pending dangerous command instead. Security concern raised by @FlyByNight69420 in #1888 and addressed by @solo386 in PR #1971.

The fix: Rather than patching the text matching, replaced the entire mechanism:

  • Removed bare text matching (yes, y, approve, ok, go, do it, etc.)
  • Added /approve and /deny as gateway-only slash commands in the command registry
  • /approve supports scoping:
    • /approve — one-time execution
    • /approve session — approve this pattern for the session
    • /approve always — approve permanently
  • 5-minute timeout — stale approvals expire automatically
  • Structured instructions — gateway appends clear /approve / /deny instructions to the agent response when a dangerous command is pending

Test Plan

9 tests in tests/gateway/test_approve_deny_commands.py:

  • ✅ /approve executes pending command
  • ✅ /approve session remembers pattern
  • ✅ /approve always approves permanently
  • ✅ /approve with no pending returns helpful message
  • ✅ /approve on expired approval rejects
  • ✅ /deny clears pending approval
  • ✅ /deny with no pending returns helpful message
  • ✅ Bare "yes" does NOT execute pending command (the original bug)
  • ✅ Approval hint format verification

All 1211 gateway tests + 72 approval tests pass.

…ands

The gateway approval system previously intercepted bare 'yes'/'no' text
from the user's next message to approve/deny dangerous commands. This was
fragile and dangerous — if the agent asked a clarify question and the user
said 'yes' to answer it, the gateway would execute the pending dangerous
command instead. (Fixes #1888)

Changes:
- Remove bare text matching ('yes', 'y', 'approve', 'ok', etc.) from
  _handle_message approval check
- Add /approve and /deny as gateway-only slash commands in the command
  registry
- /approve supports scoping: /approve (one-time), /approve session,
  /approve always (permanent)
- Add 5-minute timeout for stale approvals
- Gateway appends structured instructions to the agent response when a
  dangerous command is pending, telling the user exactly how to respond
- 9 tests covering approve, deny, timeout, scoping, and verification
  that bare 'yes' no longer triggers execution

Credit to @solo386 and @FlyByNight69420 for identifying and reporting
this security issue in PR #1971 and issue #1888.
@teknium1 teknium1 merged commit 7b6d14e into main Mar 18, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant