mirror of
https://github.com/RoboSats/robosats.git
synced 2025-08-08 00:20:08 +00:00
Prevent timing attacks on protected orders
This commit is contained in:
12
api/views.py
12
api/views.py
@ -1,4 +1,5 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from hmac import compare_digest
|
||||||
|
|
||||||
from decouple import config
|
from decouple import config
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -558,11 +559,12 @@ class OrderView(viewsets.ViewSet):
|
|||||||
if not valid:
|
if not valid:
|
||||||
return Response(context, status=status.HTTP_409_CONFLICT)
|
return Response(context, status=status.HTTP_409_CONFLICT)
|
||||||
|
|
||||||
if order.password is not None and order.password != password:
|
if order.password is not None:
|
||||||
return Response(
|
if password is None or not compare_digest(order.password, password):
|
||||||
{"bad_request": "Wrong password"},
|
return Response(
|
||||||
status=status.HTTP_403_FORBIDDEN,
|
{"bad_request": "Wrong password"},
|
||||||
)
|
status=status.HTTP_403_FORBIDDEN,
|
||||||
|
)
|
||||||
|
|
||||||
# For order with amount range, set the amount now.
|
# For order with amount range, set the amount now.
|
||||||
if order.has_range:
|
if order.has_range:
|
||||||
|
Reference in New Issue
Block a user