Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
push_notifications: Use constant-time compare for transfer token.
Tim Abbottbeb599feeb4f
diff --git a/zerver/views/push_notifications.py b/zerver/views/push_notifications.pyindex dec9168812c..0b25a910f17 100644--- a/zerver/views/push_notifications.py+++ b/zerver/views/push_notifications.py@@ -6,6 +6,7 @@ from django.db import transactionfrom django.http import HttpRequest, HttpResponse, HttpResponseRedirectfrom django.shortcuts import renderfrom django.urls import reverse+from django.utils.crypto import constant_time_comparefrom django.utils.translation import gettext as _from pydantic import Json@@ -294,7 +295,7 @@ def self_hosting_registration_transfer_challenge_verify(raise VerificationSecretNotPreparedErrordata = orjson.loads(json_data)- if data["access_token"] != access_token:+ if not constant_time_compare(data["access_token"], access_token):# Without knowing the access_token, the client gets the same error# as if we're not serving the verification secret at all.raise VerificationSecretNotPreparedError