Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

webhooks: Check HMAC signature with constant_time_compare.

Anders Kaseorg149a99396c00
diff --git a/zerver/lib/webhooks/common.py b/zerver/lib/webhooks/common.py
index 296441276b3..21bc7f73718 100644
--- a/zerver/lib/webhooks/common.py
+++ b/zerver/lib/webhooks/common.py
@@ -10,6 +10,7 @@ from urllib.parse import unquote
from django.conf import settings
from django.http import HttpRequest
+from django.utils.crypto import constant_time_compare
from django.utils.encoding import force_bytes
from django.utils.translation import gettext as _
from pydantic import Json
@@ -341,7 +342,7 @@ def validate_webhook_signature(
algorithm,
).hexdigest()
- if signed_payload != signature:
+ if not constant_time_compare(signed_payload, signature):
raise JsonableError(_("Webhook signature verification failed."))