Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
scim: Check SCIM tokens using constant-time comparison.
Anders Kaseorg2cc3fa4fba36
diff --git a/zerver/middleware.py b/zerver/middleware.pyindex e30e2d1e171..a023a813999 100644--- a/zerver/middleware.py+++ b/zerver/middleware.py@@ -15,6 +15,7 @@ from django.middleware.locale import LocaleMiddleware as DjangoLocaleMiddlewarefrom django.shortcuts import renderfrom django.utils import translationfrom django.utils.cache import patch_vary_headers+from django.utils.crypto import constant_time_comparefrom django.utils.deprecation import MiddlewareMixinfrom django.utils.log import log_responsefrom django.utils.translation import gettext as _@@ -725,7 +726,10 @@ def validate_scim_bearer_token(request: HttpRequest) -> bool:assert valid_bearer_tokenassert scim_client_name- if request.headers.get("Authorization") != f"Bearer {valid_bearer_token}":+ authorization = request.headers.get("Authorization")+ if authorization is None or not constant_time_compare(+ authorization, f"Bearer {valid_bearer_token}"+ ):return Falserequest_notes = RequestNotes.get_notes(request)