Skip to content

Commit b1b6a2b

Browse files
committed
Fix hmac comparision to be secure (thanks @erikh360)
1 parent 3ec0e99 commit b1b6a2b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

registrations/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ def validate_signature(self, request):
684684

685685
h = hmac.new(secret.encode(), request.body, sha256)
686686

687-
if base64.b64encode(h.digest()).decode() != signature:
687+
if not hmac.compare_digest(base64.b64encode(h.digest()).decode(), signature):
688688
raise AuthenticationFailed("Invalid hook signature")
689689

690690
def get_msisdn(self, data):

0 commit comments

Comments
 (0)