mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #213] API key: an empty value silently disables authentication, and the key is compared with == #111
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#111
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @alphastorm on GitHub (Sep 30, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/213
Two small hardening points in the API key check (serve/server.py#L1243-L1251):
--api-keydefaults to$STRATA_API_KEY(#L1669-L1670), and an empty value falls back to the config'sapi_key(#L1727); when both are empty,_authorized()lets every request through. The "no API key" warning is printed only for other hosts (#L1752-L1761); on 127.0.0.1 the ready line just leaves out ", API key required". A launcher that meant to set a key but exported an emptySTRATA_API_KEYgets an open server and no sign of it.==(given == svc.api_key), which is not a constant-time comparison.hmac.compare_digest(given.encode(), svc.api_key.encode())is the usual replacement.Suggested: refuse to start, or at least warn on every host, when
--api-keyorSTRATA_API_KEYis given but empty, and compare withhmac.compare_digest.@Niko1221 commented on GitHub (Sep 30, 2026):
Good points. 0.1.28 (in testing) compares the key in constant time (
hmac.compare_digest), and an explicitly empty key (--api-key ""or an emptySTRATA_API_KEY) stops the server with a message instead of switching authentication off.@Niko1221 commented on GitHub (Sep 30, 2026):
Fixed in 0.1.28: constant-time comparison (
hmac.compare_digest), and an explicitly empty key (--api-key ""or an emptySTRATA_API_KEY) stops the server with a message.