openai_server: constant-time API key check (hmac.compare_digest) + resource_plan: csv-parse GPU names (fixes comma-in-name drop) (#186)

P6: discover_gpus() used line.split(',', 3) to parse nvidia-smi CSV output.
    If the GPU name contains a comma (e.g. 'Tesla, Inc. V100'), split produces
    more than 4 fields, the int() parse fails on the wrong field, and the GPU
    is silently dropped — doctor reports 'no NVIDIA device detected' with no
    clue why. Fixed by using the csv module (handles quoted fields correctly).

P7: require_auth() used plain string != comparison for the API key
    ('Authorization' header vs expected 'Bearer <key>'). This enables a
    timing side-channel that could leak the key byte-by-byte. Low impact when
    bound to localhost (default), but serve() only warns when host is
    non-localhost without a key, and users do expose on 0.0.0.0. Fixed by
    using hmac.compare_digest (constant-time comparison).

Co-authored-by: woolcoxm <13604288+woolcoxm@users.noreply.github.com>
This commit is contained in:
woolcoxm
2026-07-14 08:16:31 -04:00
committed by GitHub
parent 8395435322
commit 39dcebf39a
2 changed files with 10 additions and 5 deletions
+3 -2
View File
@@ -151,8 +151,9 @@ def discover_gpus():
except (OSError, subprocess.SubprocessError):
return []
devices = []
for line in result.stdout.splitlines():
fields = [field.strip() for field in line.split(",", 3)]
import csv
for fields in csv.reader(result.stdout.splitlines()):
fields = [f.strip() for f in fields]
if len(fields) != 4:
continue
try: