Skip to content

[Bug]: plain /approve in gateway grants session-wide approval instead of one-time approval #4697

Closed as not planned

Description

@Tranquil-Flow

Bug Description

In gateway/blocking approval mode, replying with plain /approve is documented as approving the oldest pending dangerous command once, but the implementation persists a session-wide approval for the matched danger pattern.

Steps to Reproduce

  1. Start a gateway session with dangerous-command approvals enabled.
  2. Trigger a dangerous command such as rm -rf /important.
  3. Reply with /approve.
  4. Trigger the same dangerous command again in the same session.

Expected Behavior

The second dangerous command should require a fresh approval, because plain /approve is a one-time approval.

Actual Behavior

The second dangerous command is auto-approved in the same session.

Affected Component

  • Gateway (Telegram/Discord/Slack/WhatsApp)
  • Tools (approval flow)

Messaging Platform

  • Any gateway platform using the blocking approval flow

Operating System

Containerized Linux environment

Python Version

3.11.15

Hermes Version

0.6.0 / current main at commit 924bc67e

Relevant Logs / Traceback

No traceback — behavior bug confirmed with regression test.

Root Cause Analysis

In tools/approval.py, the blocking gateway approval persistence logic currently treats choice == "once" the same as choice == "session" and calls approve_session(session_key, key) in both cases.

That makes plain /approve session-scoped instead of one-time.

Proposed Fix

Only persist session approval for choice == "session". Keep "once" non-persistent, matching the documented and CLI semantics.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Activity

  1. added
    type/securitySecurity vulnerability or hardening
    P1High — major feature broken, no workaround
    comp/gatewayGateway runner, session dispatch, delivery
    comp/toolsTool registry, model_tools, toolsets
    on May 1, 2026
  2. teknium1 commented on Jun 10, 2026

    @teknium1
    Collaborator

    This bug has been fixed on main — closing as implemented.

    Commit ef3bd3b (security(approval): fix privilege escalation in gateway once-approval logic, merged 2026-04-03) directly addresses the root cause you identified:

    • Before: if choice in ("once", "session") — once-approval incorrectly called approve_session(), making it session-scoped.
    • After: if choice == "session" — only "session" and "always" persist; "once" is explicitly left non-persistent with an explanatory comment.

    The fix is visible in tools/approval.py around line 821 in current main. Thank you for the detailed root-cause analysis — it made the fix straightforward.

    This is an automated hermes-sweeper review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High — major feature broken, no workaroundcomp/gatewayGateway runner, session dispatch, deliverycomp/toolsTool registry, model_tools, toolsetssweeper:implemented-on-mainSweeper: behavior already present on current maintype/securitySecurity vulnerability or hardening

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions