This page documents the security architecture, user authorization mechanisms, and command approval systems for the Hermes Agent messaging gateway. It details how the system handles allowlist filtering, the Direct Message (DM) pairing system, and the security model for dangerous command execution.
The Hermes Agent gateway implements a multi-layered authorization system to control access across messaging platforms. Authorization is evaluated to determine if an incoming message event should be processed by an agent.
The gateway evaluates access in a specific priority order. This logic is implemented via GatewayAuthorizationMixin, which provides the authorization methods for the GatewayRunner gateway/authz_mixin.py61-64
| Priority | Check Type | Code Entity / Configuration |
|---|---|---|
| 1 | Upstream Trust | _adapter_authorization_is_upstream gateway/authz_mixin.py155-157 |
| 2 | Platform Allowlist | _PLATFORM_ALLOWLIST_ENV (e.g., TELEGRAM_ALLOWED_USERS) gateway/pairing.py65-84 |
| 3 | DM Pairing | PairingStore.is_approved(platform, user_id) gateway/pairing.py236-260 |
| 4 | Platform Own Policy | _adapter_enforces_own_access_policy gateway/authz_mixin.py111-137 |
| Default | Deny | Fallback to unauthorized_dm_behavior gateway/authz_mixin.py6-7 |
Certain platforms enforce their own access policies at the intake layer. The gateway honors these via _adapter_enforces_own_access_policy gateway/authz_mixin.py111-137 In multiplex mode, the gateway ensures that secondary profiles do not fall back to the default profile's adapter to prevent "fail-open" misrouting gateway/authz_mixin.py80-87
Sources: gateway/authz_mixin.py61-157 gateway/pairing.py65-105
The pairing system provides a secure, code-based approval flow for authorizing new users on messaging platforms without requiring manual configuration of user IDs.
The pairing system is designed based on NIST SP 800-63-4 guidance gateway/pairing.py8-16:
ABCDEFGHJKLMNPQRSTUVWXYZ23456789 (no 0/O or 1/I) gateway/pairing.py43-44secrets.choice() gateway/pairing.py10-25CODE_TTL_SECONDS) gateway/pairing.py47PairingStore.generate_code() gateway/pairing.py203-234PairingStore.approve_code() gateway/pairing.py262-282TELEGRAM_ALLOWED_USERS), approving a code automatically appends the user to that allowlist via _sync_allowlist_add gateway/pairing.py112-139Sources: gateway/pairing.py8-53 gateway/pairing.py203-315 gateway/pairing.py112-139
The tools.approval module is the single source of truth for detecting and gating dangerous commands tools/approval.py3-9
The system maintains two tiers of command blocking:
rm -rf /tmp or chmod 777 that require user approval tools/approval.py4-6rm -rf /, mkfs, dd to block devices) that are unconditionally blocked even in YOLO mode tests/tools/test_hardline_blocklist.py1-8The system supports three approval modes configured in config.yaml tools/approval.py7-8:
_smart_approve which calls the LLM with a specific approval task profile tests/tools/test_approval.py66-78In the gateway, approvals use a blocking mechanism where the agent thread waits for a user response tests/gateway/test_approve_deny_commands.py3-5
register_gateway_notify binds a session to an approval callback tests/gateway/test_approve_deny_commands.py92-94/approve or /deny, which triggers resolve_gateway_approval to unblock the agent tests/gateway/test_approve_deny_commands.py109-110Sources: tools/approval.py3-67 tests/tools/test_approval.py16-78 tests/tools/test_hardline_blocklist.py1-138 tests/gateway/test_approve_deny_commands.py1-120
This diagram maps the logical pairing flow to internal code entities.
Sources: gateway/authz_mixin.py61-64 gateway/pairing.py43-44 gateway/pairing.py203-234 gateway/pairing.py284-315
This diagram illustrates how commands are filtered from the agent to the execution environment.
Sources: tools/approval.py3-25 tests/tools/test_approval.py16-78 tests/tools/test_hardline_blocklist.py12-22 tests/gateway/test_approve_deny_commands.py90-110 run_agent.py18-20
Refresh this wiki
This wiki was recently refreshed. Please wait 3 days to refresh again.