-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The order is the bug\n\nHere is the pre-patch ordering in `gateway/platforms/webhook.py`, the block hermes-agent's issue tracker identified as `#12544`:\n\n```python\nasync def _handle_webhook(self, request: \"web.Request\") -> \"web.Response\":\n # ... route lookup, enabled check, Content-Length cap ...\n\n # ── Rate limiting ────────────────────────────────────────\n now = time.time()\n window = self._rate_counts.setdefault(route_name, [])\n window[:] = [t for t in window if now - t < 60]\n if len(window) >= self._rate_limit:\n return web.json_response(\n {\"error\": \"Rate limit exceeded\"}, status=429\n )\n window.append(now)\n\n # Read body\n try:\n raw_body = await request.read()\n except Exception as e:\n logger.error(\"[webhook] Failed to read body: %s\", e)\n return web.json_response({\"error\": \"Bad request\"}, status=400)\n\n # Validate HMAC signature (skip for INSECURE_NO_AUTH testing mode)\n secret = route_config.get(\"secret\", self._global_secret)\n if secret and secret != _INSECURE_NO_AUTH:\n if not self._validate_signature(request, raw_body, secret):\n logger.warning(\n \"[webhook] Invalid signature for route %s\", route_name\n )\n return web.json_response(\n {\"error\": \"Invalid signature\"}, status=401\n )\n```\n\nThe window is `self._rate_counts.setdefault(route_name, [])`. The key is the route name. Not the caller IP. Not the validated signer. The route name. Every request that names the route writes a timestamp into the same array, and that array is what the next request is measured against.\n\n`window.append(now)` runs before the body is read. The body read runs before the secret lookup. The secret lookup runs before `_validate_signature`. By the time the signature check rejects an unauthenticated caller with 401, the caller has already written `now` into the route's window. The 401 is honest about the request. The timestamp it leaves behind is the bug.\n\nPR #12843, which closed the issue, swaps the two blocks:\n\n```diff\n- # ── Rate limiting ────────────────────────────────────────\n- now = time.time()\n- window = self._rate_counts.setdefault(route_name, [])\n- window[:] = [t for t in window if now - t < 60]\n- if len(window) >= self._rate_limit:\n- return web.json_response(\n- {\"error\": \"Rate limit exceeded\"}, status=429\n- )\n- window.append(now)\n-\n # Read body\n+ # Read body (must be done before any validation)\n try:\n raw_body = await request.read()\n except Exception as e:\n logger.error(\"[webhook] Failed to read body: %s\", e)\n return web.json_response({\"error\": \"Bad request\"}, status=400)\n\n- # Validate HMAC signature (skip for INSECURE_NO_AUTH testing mode)\n+ # Validate HMAC signature FIRST (skip for INSECURE_NO_AUTH testing mode)\n secret = route_config.get(\"secret\", self._global_secret)\n if secret and secret != _INSECURE_NO_AUTH:\n if not self._validate_signature(request, raw_body, secret):\n ...\n return web.json_response(\n {\"error\": \"Invalid signature\"}, status=401\n )\n\n+ # ── Rate limiting (after auth) ───────────────────────────\n+ now = time.time()\n+ window = self._rate_counts.setdefault(route_name, [])\n+ window[:] = [t for t in window if now - t < 60]\n+ if len(window) >= self._rate_limit:\n+ return web.json_response(\n+ {\"error\": \"Rate limit exceeded\"}, status=429\n+ )\n+ window.append(now)\n```\n\nZero new logic. The same nine lines that were above `_validate_signature` are now below it. The bug is the position.\n\nThe test file the same PR added, `tests/gateway/test_webhook_signature_rate_limit.py`, demonstrates the pre-fix behaviour in three cases. The headline test floods five requests carrying `X-Hub-Signature-256: sha256=invalid`, asserts each returns 401, then sends one valid-signed request and asserts it returns 202. The docstring is explicit about what the assertion would have failed at before the swap:\n\n```python\n# BEFORE FIX: This would return 429 because the 5 bad requests\n# consumed the rate limit bucket.\n# AFTER FIX: Bad requests don't touch rate limiting, so valid\n# request succeeds.\n```\n\nThe reproduction is in the same commit as the fix because the maintainers wanted regression coverage on the order, not on the logic. The logic is unchanged.\n\n## The bucket is keyed by route, not by caller\n\nThe reason the swap matters is the key. `self._rate_counts.setdefault(route_name, [])` reaches into a dictionary whose key is the route name. Route names are configured by the operator and are reachable from the URL the caller posts to (`POST /webhooks/{route_name}`). A caller who can read the route name from a successful webhook delivery's URL, scan a sitemap, guess a common name like `github` or `gitlab`, or read it from the operator's public configuration can name the bucket they want to drain.\n\nThe bucket is shared between every caller who names that route. GitHub's webhook delivery infrastructure, the operator's authenticated CI integration, a Discord bot's relay, and an anonymous HTTP client with a wordlist all wrote to the same array, because `_handle_webhook` derived the key from `route_name` and nothing else.\n\nThe fix does not change the key. The post-fix code still does `self._rate_counts.setdefault(route_name, [])` and still increments by route. The fix changes the order so that only signed requests reach `window.append(now)`. Once you have to be signed to append, the bucket is implicitly per-signer, because only holders of the route secret can write to it. The per-route bucket and the per-signer bucket are now the same set, because the gate decides who is allowed to be in either.\n\nThis is the pattern. A throttle, rate-limit, or budget counter increments at request entry, before the authentication check that determines whose budget is being spent. When the bucket is keyed by route, target, or shared identity rather than by per-caller credential, unauthenticated callers debit the authenticated bucket. The 401 rejects the request; it does not refund the counter. Call it [quota-before-auth](/patterns/quota-before-auth).\n\nQuota-before-auth inverts the conventional advice. The conventional advice is to put rate limiting at the edge so the auth check is not the load-bearing CPU sink: protect the database, the public-key crypto, the OIDC roundtrip. The conventional advice is correct when the auth check is expensive. HMAC SHA-256 over a webhook body is microseconds. There was no compute reason to put the rate limit ahead of it. The order shipped because the developer reached for the conventional pattern without checking whether the bucket and the auth check were measuring the same caller.\n\n## The CVE record names the wrong file\n\nCVE-2026-10224's NVD description identifies the affected location as the function `_handle_webhook_request` in `gateway/platforms/feishu.py`. Both names are real. `feishu.py` is the Feishu/Lark adapter, which runs its own webhook server for the lark_oapi event dispatch chain. Its handler is named `_handle_webhook_request` and looks like this on main:\n\n```python\nasync def _handle_webhook_request(self, request: web.Request) -> web.Response:\n \"\"\"Process incoming Feishu webhook POST.\"\"\"\n if not self._event_handler:\n return web.Response(status=503, text=\"Event handler not ready\")\n\n # Rate limiting and anomaly tracking\n client_ip = self._extract_client_ip(request)\n if self._is_rate_limited(client_ip):\n return web.Response(status=429)\n\n try:\n body = await request.read()\n if len(body) > _FEISHU_WEBHOOK_MAX_BODY_BYTES:\n return web.Response(status=413)\n\n challenge = self._event_handler.invoke(body)\n ...\n```\n\n`feishu.py`'s rate limiter is keyed by `client_ip`. `feishu.py`'s authentication is delegated into Feishu's `EventDispatcherHandler` constructed with `self._encrypt_key` and `self._verification_token`, not into an HMAC primitive at all. The shape of the per-IP bucket means the cross-tenant debit the CVE describes cannot happen here: an attacker debits their own IP's bucket, not the legitimate Feishu delivery IPs'. `feishu.py` does not carry the bug the CVE describes.\n\nThe bug is in `webhook.py`. The function is `_handle_webhook`. The fix is in `webhook.py`. The test added in PR #12843 imports from `gateway.platforms.webhook`, mounts `WebhookAdapter._handle_webhook` as `POST /webhooks/{route_name}`, and proves the issue with `X-Hub-Signature-256` headers, the GitHub-flavoured HMAC primitive. The bug never touched Feishu's `_encrypt_key`/`_verification_token` path. The CVE record names a method in the wrong file, at the wrong call site, with the wrong authentication primitive.\n\n`webhook.py` is the generic webhook adapter hermes-agent ships for any service speaking the GitHub HMAC convention: GitHub, GitLab, Slack via signing secrets, custom internal webhooks the operator wires up themselves. Every route configured against `webhook.py` shared the same pre-auth bucket. The CVE record names one consumer of one of hermes-agent's gateway platforms, the one the original reporter happened to be integrating. The bug lives in the platform every operator using `secret:` configuration ran.\n\n## The same patch added a fail-closed guard the CVE does not name either\n\nThe diff in PR #12843 contains a second change that is not about ordering. Before the patch, the secret check read:\n\n```python\nsecret = route_config.get(\"secret\", self._global_secret)\nif secret and secret != _INSECURE_NO_AUTH:\n if not self._validate_signature(request, raw_body, secret):\n ...\n```\n\nAfter:\n\n```python\nsecret = route_config.get(\"secret\", self._global_secret)\nif not secret:\n logger.error(\n \"[webhook] Route %s has no HMAC secret; refusing request\",\n route_name,\n )\n return web.json_response(\n {\"error\": \"Webhook route is missing an HMAC secret\"},\n status=403,\n )\nif secret != _INSECURE_NO_AUTH:\n if not self._validate_signature(request, raw_body, secret):\n ...\n```\n\nThe comment the maintainers wrote into the post-fix code spells out why: \"Missing/empty secrets must fail closed here, not only during connect(), so direct handler reuse cannot turn a network webhook route into an unauthenticated agent-dispatch surface.\"\n\nBefore this change, a route whose `secret` field resolved to an empty string or `None` walked through both checks. `if secret and secret != _INSECURE_NO_AUTH:` is false when `secret` is falsy, so the signature check was skipped. The handler then read the body, parsed the payload, and dispatched it to the agent. A misconfigured route, a route whose secret was cleared during a hot-reload of the subscriptions file, or a route whose operator set `secret: \"\"` thinking that meant \"no auth for local testing\" became an unauthenticated path into hermes-agent's message-handling pipeline. Direct handler reuse, the case the comment calls out, means any code path that registered an aiohttp route against this method without going through `connect()` skipped the only other place an empty-secret check was enforced.\n\nCVE-2026-10224 does not mention this. The CWE-400 classification (Uncontrolled Resource Consumption) does not cover it. The hermes-agent maintainers fixed it in the same commit because they were already in that code and the same trust boundary was failing twelve lines down. Two bugs, one patch, one CVE description that names neither one accurately.\n\n## The disclosure path is in the filename\n\nThe disclosure markdown lives at `gist.github.com/YLChen-007/0304e313d811f187ade93d3b01de0f87`. The file in that gist is named `Issue-hermes-agent-12544-feishu-webhook-auth-order-ISSUE-REPORT.md`. The two PoC scripts the advisory references, `poc_Issue-hermes-agent-12544-feishu-webhook-auth-order.py` and `control-valid-signed-request-no-preflood.py`, do not exist as files in the gist. They are named in the advisory's reproduction-steps section and never published.\n\nThe CVE description is downstream of that advisory. The VulDB submission was downstream of the advisory. Both inherited the filename's word \"feishu\" as the location of the bug, because the original reporter was integrating Feishu when they encountered it. Neither downstream stage looked at the upstream issue, which says `gateway/platforms/webhook.py:298-324` in plain text in its body. Neither downstream stage looked at PR #12843, which touches `gateway/platforms/webhook.py` and not `gateway/platforms/feishu.py`. The public record carries the word \"feishu\" because the reporter's email signature did, and nobody between the reporter and NVD opened the file the reporter named.","closing_line":"The patch is in webhook.py. The CVE description still points at feishu.py. The first thing a defender does after a CVE alert is grep the file the CVE names.","hook_md":"NousResearch hermes-agent's webhook adapter has a method called `_handle_webhook`. It runs five gates in order: route exists, route is enabled, Content-Length is under the cap, route-keyed rate-limit counter is under quota, HMAC signature matches the route secret. CVE-2026-10224 is the gate at position four debiting the counter the gate at position five was supposed to authenticate. Unauthenticated callers spend the authenticated caller's quota, and the 401 they collect on their way out is the receipt for the debit they just put on the victim's account.\n\nThe CVE record names `gateway/platforms/feishu.py` and the function `_handle_webhook_request`. Both exist in the repository. Neither carries the bug. The bug is in `gateway/platforms/webhook.py`, in `_handle_webhook`, in a rate-limit block PR #12843 moved to run after the signature check the CVE description does not mention.","post_id":589,"slug":"hermes-agent-cve-2026-10224-quota-before-auth","title":"CVE-2026-10224: Hermes Agent's Webhook Debited The Quota Before It Checked The Signature, And The CVE Record Names The Wrong File","type":"initial","unreadable_sentence":"The 401 an unauthenticated caller collects is the receipt for the debit they just put on the victim's account."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCasACOgAKCRDeZjl4jgkQ JhKLAQDpFv20fExlW4o+3cAxAcqkzHSUiGC9ikLMxfjy7m+qkAD/Wss9EOcvAn04 bvIfU1OlfiD0TmeTgnOnJuOCtSQegAk= =BmBd -----END PGP SIGNATURE-----