Skip to content

Commit dc32b04

Browse files
authored
fix: use constant-time comparison for auth token (CWE-208) (#227)
1 parent 3ed558b commit dc32b04

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

proxypool/processors/server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import hmac
12
from flask import Flask, g, request
23
from proxypool.exceptions import PoolEmptyException
34
from proxypool.storages.redis import RedisClient
@@ -22,7 +23,7 @@ def decorator(*args, **kwargs):
2223
else:
2324
return {"message": "Please provide an API key in header"}, 400
2425
# Check if API key is correct and valid
25-
if request.method == "GET" and api_key == API_KEY:
26+
if request.method == "GET" and hmac.compare_digest(api_key, API_KEY):
2627
return func(*args, **kwargs)
2728
else:
2829
return {"message": "The provided API key is not valid"}, 403

0 commit comments

Comments
 (0)