fix: prevent timing attack on /api/nodes admin key check#4067
fix: prevent timing attack on /api/nodes admin key check#4067BossChaos wants to merge 2 commits intoScottcjn:mainfrom
Conversation
1. Replace == string comparison with hmac.compare_digest() in api_nodes() 2. Mitigates side-channel timing attacks on RC_ADMIN_KEY verification
haoyousun60-create
left a comment
There was a problem hiding this comment.
Reviewed. Security hardening looks solid. LGTM! 🚀
fengqiankun6-sudo
left a comment
There was a problem hiding this comment.
PR Review: Timing Attack Prevention (PR #4067)
Author: @BossChaos
Scope: 1 meaningful file changed (+1, -1)
Labels: BCOS-L1, size/XS, node
Summary
Replaces direct string comparison (==) with hmac.compare_digest() for admin key validation to prevent timing attacks.
Code Review
node/rustchain_v2_integrated_v2.2.1_rip200.py:
# Before (vulnerable to timing attack)
return bool(need and got and need == got)
# After (constant-time comparison)
return bool(need and got and hmac.compare_digest(need, got))Assessment: ✅ Excellent Security Fix
-
Timing attack vulnerability — The original
==comparison returnsFalseas soon as it finds a mismatched character. An attacker could measure response times to guess the admin key byte-by-byte. -
hmac.compare_digest— This performs constant-time comparison regardless of where the first difference occurs, preventing timing side-channel attacks. -
Low impact — No API changes; just a security hardening.
Est. Reward: Security-focused — 15-25 RTC
Recommended: Approve
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) |
==string comparison withhmac.compare_digest()inapi_nodes()RC_ADMIN_KEYverification