The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webhook): a whsec_ Svix secret that decodes to an empty or blank key fails closed
kshitijk4poorb0ea19a9cd04
diff --git a/gateway/platforms/webhook.py b/gateway/platforms/webhook.pyindex fc886965a04..9cb204261d8 100644--- a/gateway/platforms/webhook.py+++ b/gateway/platforms/webhook.py@@ -174,6 +174,8 @@ def _validate_svix_signature(body: bytes, secret: str, msg_id: str, timestamp: sexcept (binascii.Error, ValueError):logger.debug("[webhook] Invalid whsec_ Svix signing secret")return False+ if not key.strip(): # "whsec_" alone decodes to b"": a public HMAC key, same as a blank secret+ return Falseelse:# Some providers document Svix-style headers but hand out raw shared secrets.logger.debug("[webhook] Validating Svix-style signature with raw secret")diff --git a/tests/gateway/test_webhook_adapter.py b/tests/gateway/test_webhook_adapter.pyindex db0d1898f6a..62e3abff2de 100644--- a/tests/gateway/test_webhook_adapter.py+++ b/tests/gateway/test_webhook_adapter.py@@ -278,6 +278,8 @@ class TestValidateSignature:("real-secret", "attacker-secret", b'{"a":1}', b'{"a":1}', False, False),("real-secret", None, b'{"a":1}', b'{"a":2}', False, False), # tampered body("real-secret", None, b'{"a":1}', b'{"a":1}', True, False), # replayed stale timestamp+ ("whsec_", None, b'{"a":1}', b'{"a":1}', False, False), # decodes to an empty key+ ("whsec_ICAg", None, b'{"a":1}', b'{"a":1}', False, False), # decodes to whitespace],)def test_standard_webhooks_headers_validate_like_svix(self, secret, sign_with, body, received, stale, expected):