fix(gateway): own-policy adapters fail open without allowlists - #38639
fix(gateway): own-policy adapters fail open without allowlists#38639coygeek wants to merge 1 commit into
Conversation
Require adapter-owned gateway authorization to be backed by a concrete configured allowlist before bypassing the gateway default-deny path. Open dm_policy/group_policy settings now fall through unless the operator also configured an explicit allow-all or allowlist. Add regression coverage for open DM/group denial, config-only allowlist acceptance, and non-matching sender rejection across own-policy adapters.
tonydwb
left a comment
There was a problem hiding this comment.
Review: PR #38639 — fix(gateway): own-policy adapters fail open without allowlists
Verdict: Approved
Narrows the security contract so dm_policy: open / group_policy: open can no longer implicitly authorize all callers:
_source_matches_configured_access_policyrequires a concrete configured allowlist before the gateway trusts an adapter's intake decision.- Adds normalization helpers for YUANBAO (
group:prefix), WECOM/QQBOT (case +wecom:prefix).
Looks Good
- Expands the test matrix: open vs. allowlisted DM and group paths for YUANBAO/WECOM/QQBOT, plus guild-aware QQBot matching.
- Removes the prior over-broad “trust the adapter flag” fast-path that was the root cause of the fail-open.
Minor suggestion (non-blocking)
_group_extrais on the hot path for every group message — consider caching/memoization if latency profiles show it material.
|
merge conflicts This PR is currently not reviewable against current git merge-tree --write-tree origin/main origin/pr/38639The local result was Signed: GPT-5-high in Codex |
|
Thanks for the security analysis. This is an automated hermes-sweeper review: the requested fail-closed behavior is already implemented on current
Closing as implemented on main. |
Summary
With no environment allowlist configured, an own-policy adapter such as QQBot can accept a remote caller under its default-open DM or group policy and the gateway then returns authorized before checking
GATEWAY_ALLOW_ALL_USERS.The protected resource is Hermes work dispatch and output delivery across a network-facing gateway adapter.
Truefor own-policy adapters.open, not allowlist-only or disabled.Truefor any policy other thandisabledorallowlist.Keep the gateway default-deny unless the adapter proves a non-empty caller allowlist, or change default own-policy adapter settings from
opento allowlist-only or disabled.Linked context
Closes #38638
Real behavior proof (required for external PRs)
Affected component (issue scope)
File:
gateway/run.py:7087-7098Secondary paths:
gateway/platforms/base.py:1850-1869documents own-policy adapter trust;gateway/platforms/qqbot/adapter.py:210-217defaults DM/group policy toopen;gateway/platforms/qqbot/adapter.py:3139-3151allows non-disabled policies.Files changed in this PR
gateway/run.pygateway/platforms/qqbot/adapter.pytests/gateway/test_config_driven_access_policy.pyBehavior reproduced or verified
maincommitf66a929a6b78b81bd31a634f05798431b0fb10aa, enable QQBot with valid credentials and leave all QQ/Gateway allowlists unset.dm_policyandgroup_policyomitted so QQBot defaults them toopen.GatewayRunner._is_user_authorized()returnsTruethrough the own-policy branch.Expected fixed behavior
Keep the gateway default-deny unless the adapter proves a non-empty caller allowlist, or change default own-policy adapter settings from
opento allowlist-only or disabled.Tests and validation
bash scripts/run_tests.sh tests/gateway/test_config_driven_access_policy.pyEnvironment
Verified against latest upstream
mainvia source receipt (source_ready,upstream-main,f66a929a6b78b81bd31a634f05798431b0fb10aa). Full-public submit-fix route is approved for public issue plus linked review-ready PR publication. Redaction checked: no secrets, tokens, credentials, private logs, or unrelated local paths are included.Risk checklist