Skip to content

SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.

[fix] use hmac.compare_digest instead of ==

Alexandre Flamentd7848702097c
diff --git a/searx/webapp.py b/searx/webapp.py
index a7812f181..788e0d24f 100755
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -1067,8 +1067,9 @@ def image_proxy():
if not url:
return '', 400
- h = new_hmac(settings['server']['secret_key'], url.encode())
- if h != request.args.get('h'):
+ h_url = new_hmac(settings['server']['secret_key'], url.encode())
+ h_args = request.args.get('h')
+ if len(h_url) != len(h_args) or not hmac.compare_digest(h_url, h_args):
return '', 400
maximum_size = 5 * 1024 * 1024