Use constant-time comparison for bearer token validation #8

Closed
opened 2026-02-20 06:51:49 +00:00 by cal · 1 comment
Owner

`app/dependencies.py:38` — `return token == AUTH_TOKEN`. Python string `==` short-circuits on first mismatch. Use `hmac.compare_digest()` instead.

Priority: low

\`app/dependencies.py:38\` — \`return token == AUTH_TOKEN\`. Python string \`==\` short-circuits on first mismatch. Use \`hmac.compare_digest()\` instead. **Priority**: low
cal added the
security
label 2026-02-20 06:51:49 +00:00
cal added the
ai-working
label 2026-03-04 05:30:59 +00:00
cal removed the
ai-working
label 2026-03-04 05:31:44 +00:00
Author
Owner

Fixed in PR #56: #56

Added import hmac and replaced token == AUTH_TOKEN with hmac.compare_digest(token, AUTH_TOKEN) in app/dependencies.py to prevent timing side-channel attacks on bearer token validation.

Fixed in PR #56: https://git.manticorum.com/cal/paper-dynasty-database/pulls/56 Added `import hmac` and replaced `token == AUTH_TOKEN` with `hmac.compare_digest(token, AUTH_TOKEN)` in `app/dependencies.py` to prevent timing side-channel attacks on bearer token validation.
cal added the
ai-pr-opened
label 2026-03-04 05:31:49 +00:00
cal closed this issue 2026-03-05 03:44:14 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/paper-dynasty-database#8
No description provided.