You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
verify_hmac_sha256_signature (api/webhook_auth.py) compares two strs with hmac.compare_digest(expected, signature). Python's compare_digest only supports ASCII when given str arguments — a non-ASCII byte in the attacker-controlled signature header raises:
TypeError: comparing strings with non-ASCII characters is not supported
(reproduced on Python 3: hmac.compare_digest('sha256=abc', 'sha256=\xff\xfe')). HTTP headers are latin-1-decodable, so non-ASCII values are reachable from the wire. An unauthenticated request with a garbage signature header turns into an unhandled TypeError → HTTP 500 instead of a clean 401/403 on every endpoint that calls verify_webhook_request (github/alertmanager/manual webhooks), and the same pattern exists in verify_slack_signature's final compare.
Suggested fix
Either compare bytes (hmac.compare_digest(expected.encode(), signature.encode('latin-1', 'ignore'))-style after validation), or guard the compare with a try/except TypeError: return False. One or two lines in verify_hmac_sha256_signature and verify_slack_signature.
Note
This was first spotted during the PR #24 work (the pre-consolidation verify_github_signature had the same flaw); re-verified today against current main after the webhook_auth.py refactor — it carried over.
Happy to submit a PR with the fix + regression tests once your develop-branch migration and #20 consolidation settle — just say the word.
Filed with AI assistance (Claude); the TypeError was reproduced by execution before filing.
Activity