fix: prevent timing attack on beacon admin key authentication#4045
fix: prevent timing attack on beacon admin key authentication#4045BossChaos wants to merge 2 commits intoScottcjn:mainfrom
Conversation
haoyousun60-create
left a comment
There was a problem hiding this comment.
Solid security fix. The implementation looks clean and addresses the vulnerability properly. LGTM! 🚀
fengqiankun6-sudo
left a comment
There was a problem hiding this comment.
PR #4045 Security Review
Summary
Prevents timing attack on beacon admin key authentication.
Code Assessment
- Correctness: hmac.compare_digest usage
- Coverage: Beacon admin key authentication
- Consistency: Follows established pattern
Severity: SECURITY
Timing attacks on beacon admin auth.
Estimated RTC: 10-15
fengqiankun6-sudo
left a comment
There was a problem hiding this comment.
LGTM! Good security fix. ✅
|
Closing per branch-contamination audit (2026-05-09). This PR is part of a 161-PR cluster from your account where the diff carries files unrelated to the claimed fix. Specifically, 128 of 161 PRs in this batch modify This is a branching-hygiene problem, not a quality problem with the underlying fixes. The pattern means:
To get back to paid status:
I have nothing against the underlying fixes — quality has been good when scoped. But contamination at this scale is unreviewable, and Faucet Tiers policy requires clean diffs for security claims. Specifically clean PRs already approved for payout (per 2026-05-06 audit, still scope-clean as of today):
These will be paid via the admin /wallet/transfer flow. — auto-triage 2026-05-09 (this is mechanical contamination detection, not a personal judgment) |
Summary
Fixes a timing attack vulnerability in
node/beacon_x402.pywhere the admin key comparison uses Python's!=operator instead of constant-time comparison.Issue
Before (line 179):
Python's
!=string comparison short-circuits — it returnsFalseas soon as it finds a mismatching character. This means:After:
hmac.compare_digest()runs in constant time regardless of where the mismatch occurs, eliminating the timing side channel.Note
The
BEACON_ADMIN_KEYconfiguration already properly fails closed (returns 503 if not set), so the only issue was the comparison method itself.Testing
import hmacbridge_api.py,comment-moderation-bot)