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
The admin guard in node/sophia_governor.py compares attacker-controlled header input to RC_ADMIN_KEY with raw string equality instead of hmac.compare_digest.
Python string equality is not a constant-time secret comparison. An attacker who can make repeated requests to these endpoints can use response-time differences to distinguish partially correct admin key guesses from fully incorrect guesses, which weakens the secrecy of RC_ADMIN_KEY.
RustChain already tracks this as a real bug class elsewhere in the repo (for example #3229 on sophia_governor_review_service.py), but node/sophia_governor.py still uses the timing-sensitive pattern.
Steps to reproduce
Configure RC_ADMIN_KEY and start the Flask app with register_sophia_governor_endpoints(...) enabled.
Send many POST requests to /sophia/governor/review or /sophia/governor/retry/<event_id> with candidate X-Admin-Key values of the same length.
Compare average response times for guesses with progressively longer correct prefixes versus guesses with fully incorrect prefixes.
Observe that the current implementation uses raw provided == required, so it does not provide constant-time comparison semantics for the secret.
Expected behavior
The admin guard should compare secrets with hmac.compare_digest(...) so prefix-dependent timing information is not exposed.
Actual behavior
The route guard uses raw string equality on a secret admin key.
It switches the Sophia governor admin guard to hmac.compare_digest, adds a focused regression test for /sophia/governor/review, and keeps the existing governor tests passing.
/attempt I can fix this timing-sensitive admin key comparison by implementing hmac.compare_digest as suggested. Payout address: RTC9d7caca3039130d3b26d41f7343d8f4ef4592360
Activity
github-actions commentedon May 11, 2026
Welcome to RustChain! Thanks for opening your first issue.
New here? Check out these resources:
Earn RTC tokens by contributing code, docs, or security fixes. Every merged PR gets paid!
1 RTC = $0.10 USD |
pip install clawrtcto start miningminyanyi commentedon May 11, 2026
Submitted PR #4659 for this: #4659
It switches the Sophia governor admin guard to
hmac.compare_digest, adds a focused regression test for/sophia/governor/review, and keeps the existing governor tests passing.Validation:
python -m pytest node/tests/test_sophia_governor.py -q-> 8 passedpython -m py_compile node/sophia_governor.py node/tests/test_sophia_governor.pygit diff --checkpython tools/bcos_spdx_check.py --base-ref origin/main-> OKWallet:
0x2E4380d2e1668Ca9fA3Ef91fF776FDc140Cf3fE8IgorGanapolsky commentedon May 11, 2026
/attempt I can fix this timing-sensitive admin key comparison by implementing hmac.compare_digest as suggested. Payout address: RTC9d7caca3039130d3b26d41f7343d8f4ef4592360