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.

decorator: Check Tornado secret with constant-time comparison.

Anders Kaseorg668a215ef935
diff --git a/zerver/decorator.py b/zerver/decorator.py
index 904fca61303..1739137f5c6 100644
--- a/zerver/decorator.py
+++ b/zerver/decorator.py
@@ -921,7 +921,9 @@ def is_local_addr(addr: str) -> bool:
# secret, and also the originating IP (for now).
@has_request_variables
def authenticate_notify(request: HttpRequest, secret: str = REQ("secret")) -> bool:
- return is_local_addr(request.META["REMOTE_ADDR"]) and secret == settings.SHARED_SECRET
+ return is_local_addr(request.META["REMOTE_ADDR"]) and constant_time_compare(
+ secret, settings.SHARED_SECRET
+ )
def client_is_exempt_from_rate_limiting(request: HttpRequest) -> bool: