Skip to content

Harden webhook payload parsing and gateway status topology - #40668

Open
c0nSpIc0uS7uRk3r wants to merge 1 commit into
NousResearch:mainfrom
c0nSpIc0uS7uRk3r:honcho-kimi26-gateway-hardening
Open

Harden webhook payload parsing and gateway status topology#40668
c0nSpIc0uS7uRk3r wants to merge 1 commit into
NousResearch:mainfrom
c0nSpIc0uS7uRk3r:honcho-kimi26-gateway-hardening

Conversation

@c0nSpIc0uS7uRk3r

@c0nSpIc0uS7uRk3r c0nSpIc0uS7uRk3r commented Jun 6, 2026

Copy link
Copy Markdown

Summary

  • Reject malformed JSON webhook request bodies with HTTP 400 instead of silently falling through to form parsing.
  • Keep form-encoded webhook payload fallback working for non-JSON callers.
  • Clear stale platforms entries when gateway runtime status transitions to starting, so a fresh gateway boot does not report adapters from an old topology.

Why

The webhook adapter currently attempts JSON parsing first, then falls back to form parsing on JSONDecodeError. That is useful for genuine form payloads, but it also means malformed JSON bodies with Content-Type: application/json can be reinterpreted instead of failing closed. For a webhook dispatch surface, JSON media types and JSON-looking bodies should reject malformed input before agent dispatch.

Gateway runtime status also preserves old platforms data across a new starting write. On a fresh boot, the adapter topology is redefined by the current run; stale platform entries from a previous gateway process can make status output claim adapters are present when the current gateway has not connected them.

Tests

Run against current origin/main with this PR commit only:

/home/cabo/.hermes/hermes-agent/.venv/bin/python -m py_compile gateway/platforms/webhook.py gateway/status.py tests/gateway/test_status.py tests/gateway/test_webhook_adapter.py
/home/cabo/.hermes/hermes-agent/.venv/bin/python -m pytest tests/gateway/test_webhook_adapter.py tests/gateway/test_webhook_signature_rate_limit.py tests/gateway/test_status.py -q

Result:

140 passed in 1.58s

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/webhook Webhook / API server labels Jun 6, 2026
@c0nSpIc0uS7uRk3r
c0nSpIc0uS7uRk3r force-pushed the honcho-kimi26-gateway-hardening branch from ffc0eec to 7df2234 Compare June 19, 2026 16:52
@c0nSpIc0uS7uRk3r
c0nSpIc0uS7uRk3r marked this pull request as ready for review June 19, 2026 16:53
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused gateway hardening. The two reported current-main behaviors are verified: gateway/platforms/webhook.py:550-564 falls back to form parsing after JSON decode failure, and gateway/status.py:811-845 retains the prior platforms map when writing gateway_state="starting". The proposed changes address those paths while preserving subsequent platform updates through BasePlatformAdapter._mark_connected() at gateway/platforms/base.py:2692-2703.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/webhook Webhook / API server sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants