//nefariousplan

CVE-2026-10224: Hermes Agent's Webhook Debited The Quota Before It Checked The Signature, And The CVE Record Names The Wrong File

vendor

pattern

cve

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.

The 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.

The order is the bug

Here is the pre-patch ordering in gateway/platforms/webhook.py, the block hermes-agent's issue tracker identified as #12544:

async def _handle_webhook(self, request: "web.Request") -> "web.Response":
    # ... route lookup, enabled check, Content-Length cap ...

    # ── Rate limiting ────────────────────────────────────────
    now = time.time()
    window = self._rate_counts.setdefault(route_name, [])
    window[:] = [t for t in window if now - t < 60]
    if len(window) >= self._rate_limit:
        return web.json_response(
            {"error": "Rate limit exceeded"}, status=429
        )
    window.append(now)

    # Read body
    try:
        raw_body = await request.read()
    except Exception as e:
        logger.error("[webhook] Failed to read body: %s", e)
        return web.json_response({"error": "Bad request"}, status=400)

    # Validate HMAC signature (skip for INSECURE_NO_AUTH testing mode)
    secret = route_config.get("secret", self._global_secret)
    if secret and secret != _INSECURE_NO_AUTH:
        if not self._validate_signature(request, raw_body, secret):
            logger.warning(
                "[webhook] Invalid signature for route %s", route_name
            )
            return web.json_response(
                {"error": "Invalid signature"}, status=401
            )

The 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.

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.

PR #12843, which closed the issue, swaps the two blocks:

-    # ── Rate limiting ────────────────────────────────────────
-    now = time.time()
-    window = self._rate_counts.setdefault(route_name, [])
-    window[:] = [t for t in window if now - t < 60]
-    if len(window) >= self._rate_limit:
-        return web.json_response(
-            {"error": "Rate limit exceeded"}, status=429
-        )
-    window.append(now)
-
     # Read body
+    # Read body (must be done before any validation)
     try:
         raw_body = await request.read()
     except Exception as e:
         logger.error("[webhook] Failed to read body: %s", e)
         return web.json_response({"error": "Bad request"}, status=400)

-    # Validate HMAC signature (skip for INSECURE_NO_AUTH testing mode)
+    # Validate HMAC signature FIRST (skip for INSECURE_NO_AUTH testing mode)
     secret = route_config.get("secret", self._global_secret)
     if secret and secret != _INSECURE_NO_AUTH:
         if not self._validate_signature(request, raw_body, secret):
             ...
             return web.json_response(
                 {"error": "Invalid signature"}, status=401
             )

+    # ── Rate limiting (after auth) ───────────────────────────
+    now = time.time()
+    window = self._rate_counts.setdefault(route_name, [])
+    window[:] = [t for t in window if now - t < 60]
+    if len(window) >= self._rate_limit:
+        return web.json_response(
+            {"error": "Rate limit exceeded"}, status=429
+        )
+    window.append(now)

Zero new logic. The same nine lines that were above _validate_signature are now below it. The bug is the position.

The 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:

# BEFORE FIX: This would return 429 because the 5 bad requests
# consumed the rate limit bucket.
# AFTER FIX: Bad requests don't touch rate limiting, so valid
# request succeeds.

The 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.

The bucket is keyed by route, not by caller

The 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.

The 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.

The 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.

This 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.

Quota-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.

The CVE record names the wrong file

CVE-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:

async def _handle_webhook_request(self, request: web.Request) -> web.Response:
    """Process incoming Feishu webhook POST."""
    if not self._event_handler:
        return web.Response(status=503, text="Event handler not ready")

    # Rate limiting and anomaly tracking
    client_ip = self._extract_client_ip(request)
    if self._is_rate_limited(client_ip):
        return web.Response(status=429)

    try:
        body = await request.read()
        if len(body) > _FEISHU_WEBHOOK_MAX_BODY_BYTES:
            return web.Response(status=413)

        challenge = self._event_handler.invoke(body)
        ...

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.

The 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.

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.

The same patch added a fail-closed guard the CVE does not name either

The diff in PR #12843 contains a second change that is not about ordering. Before the patch, the secret check read:

secret = route_config.get("secret", self._global_secret)
if secret and secret != _INSECURE_NO_AUTH:
    if not self._validate_signature(request, raw_body, secret):
        ...

After:

secret = route_config.get("secret", self._global_secret)
if not secret:
    logger.error(
        "[webhook] Route %s has no HMAC secret; refusing request",
        route_name,
    )
    return web.json_response(
        {"error": "Webhook route is missing an HMAC secret"},
        status=403,
    )
if secret != _INSECURE_NO_AUTH:
    if not self._validate_signature(request, raw_body, secret):
        ...

The 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."

Before 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.

CVE-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.

The disclosure path is in the filename

The 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.

The 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.

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.