[security] fix(gateway): harden callbacks, CDP, and health diagnostics - #22280
Open
Hinotoi-agent wants to merge 1 commit into
Open
[security] fix(gateway): harden callbacks, CDP, and health diagnostics#22280Hinotoi-agent wants to merge 1 commit into
Hinotoi-agent wants to merge 1 commit into
Conversation
Hinotoi-agent
force-pushed
the
security/harden-telegram-cdp-health
branch
2 times, most recently
from
May 13, 2026 03:38
06e8613 to
fa7493f
Compare
Hinotoi-agent
force-pushed
the
security/harden-telegram-cdp-health
branch
from
May 23, 2026 09:09
fc04b7e to
67c392d
Compare
This was referenced May 28, 2026
Contributor
|
Thanks for the focused hardening work. Two parts still address verified current-main gaps, while the health-endpoint portion has already landed. Problems
Suggested changes
Automated hermes-sweeper review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR hardens three small security boundaries in Hermes gateway/tool surfaces:
/health/detailednow requires API authentication when the API server is configured with an API key.The changes are intentionally narrow and covered by focused regression tests.
Security issues covered
gateway/platforms/telegram.pytools/browser_tool.pygateway/platforms/api_server.py/health/detailed, while preserving unauthenticated/healthlivenessBefore this PR
mp:,mm:,mb,mx,mg:) only checked that picker state existed for the chat._resolve_cdp_override()preserved fullws://.../devtools/browser/...endpoints directly and performed/json/versiondiscovery without first rejecting unsafe endpoint hosts./health/detailedexplicitly skipped authentication and returned gateway runtime state, platform status, active agent count, exit reason, timestamp, and PID.After this PR
_is_callback_user_authorized()with chat/thread/user context before mutating picker state./health/detaileduses_check_auth()whenever an API key is configured, matching other state-bearing API routes.Why this matters
These surfaces sit at trust boundaries that are easy to overlook because they are convenience/control-plane paths rather than primary chat message handling:
How this differs from related issue/PR
/health/detailedis distinct from the dashboard host/plugin-auth family and from basic/healthliveness checks. This PR keeps/healthunauthenticated and only protects the detailed diagnostic endpoint when an API key exists.Attack flow
Telegram model picker callback:
Explicit CDP override endpoint:
ws://.../devtools/browser/...URL directly, or performs HTTP discovery against a supplied endpoint.Detailed API health diagnostics:
/health/detailed.Affected code
gateway/platforms/telegram.py— Telegram callback dispatch for model picker actions.tools/browser_tool.py— CDP override URL normalization/discovery.gateway/platforms/api_server.py— detailed health endpoint.tests/gateway/test_telegram_approval_buttons.pytests/tools/test_browser_cdp_override.pytests/gateway/test_api_server.pyRoot cause
/health/detailedtreated a diagnostic endpoint as equivalent to a minimal liveness probe even when API auth was configured.CVSS assessment
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:L/A:N. A denied Telegram user with access to an inline button can alter model selection/state.CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N. A malicious unsafe endpoint can drive Hermes to connect/query internal browser-control or metadata surfaces when override input is accepted from a lower-trust source.CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N. Detailed platform/runtime diagnostics are disclosed without auth despite API-key configuration.Safe reproduction steps
Run the focused regression tests on vulnerable code before applying the patch:
The added/updated tests exercise:
/health/detailedreturns401without the configured API key and200with the key.Expected vulnerable behavior
On vulnerable code:
_handle_model_picker_callback()without checking the callback user./health/detailedreturns200withoutAuthorizationeven whenplatforms.api_server.keyis configured.Changes in this PR
/json/versiondiscovery requests./health/detailedwhen API auth is configured.Files changed
gateway/platforms/telegram.py,tests/gateway/test_telegram_approval_buttons.pytools/browser_tool.py,tests/tools/test_browser_cdp_override.pygateway/platforms/api_server.py,tests/gateway/test_api_server.pyMaintainer impact
/healthremains unauthenticated for liveness probes./health/detailedbehavior only affects deployments that configured an API key and were relying on unauthenticated detailed diagnostics.Fix rationale
The patch enforces the security boundary at the point where each action crosses from low-trust input into control-plane behavior:
This keeps the changes focused and avoids broad rewrites of unrelated gateway/tool behavior.
Type of change
Test plan
Commands run:
Results:
166 passed, 89 warningsruff:All checks passed!py_compile: passedDisclosure notes
This PR is intentionally bounded to three concrete, locally reproduced hardening fixes. It does not claim to redesign the entire Telegram callback model, CDP trust model, or API server observability model. Related public prior art is noted above where applicable so maintainers can review the differences quickly.