fix(remote): harden serve API access control and input handling

Bind sessions and download jobs to the API key (not source IP), reject path-traversal cache keys, bound decompression of peer-supplied blobs, gate the CDM device before the vault fallback, and compare API keys in constant time.
This commit is contained in:
imSp4rky
2026-07-06 23:54:05 -06:00
parent 84d9b92530
commit 5cd50544a8
8 changed files with 121 additions and 25 deletions
+4 -1
View File
@@ -1,3 +1,4 @@
import hmac
import logging
import subprocess
@@ -135,7 +136,9 @@ def serve(
secret_key = request.headers.get("X-Secret-Key")
if not secret_key:
return web.json_response({"status": 401, "message": "Secret Key is Empty."}, status=401)
if secret_key not in request.app["config"]["users"]:
# Constant-time compare against every configured key so a valid key can't be
# recovered byte-by-byte from response timing.
if not any(hmac.compare_digest(secret_key, k) for k in request.app["config"]["users"]):
return web.json_response({"status": 401, "message": "Secret Key is Invalid."}, status=401)
return await handler(request)