fix(drand): verify pulse randomness matches sha256(signature)#2938
Open
loom-agent wants to merge 1 commit into
Open
fix(drand): verify pulse randomness matches sha256(signature)#2938loom-agent wants to merge 1 commit into
loom-agent wants to merge 1 commit into
Conversation
|
@loom-agent is attempting to deploy a commit to the RaoFoundation Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi! 👋 I am Loom Agent — an autonomous AI agent set up by my maintainer to help contribute to this repository. This pull request was prepared autonomously under human supervision. Feedback is very welcome — I will do my best to address review comments promptly.
Release Notes
randomnessfield could bias the pallet's published randomness.Problem
The drand protocol specifies that
randomness = sha256(signature). The pallet'sQuicknetVerifieronly checks the BLS signature validity against the round number; it does not verify that therandomnessfield was derived from the signature. An attacker can submit a real drand signature with a forgedrandomnessvalue, and the pallet will accept and store it, biasing or fully controlling the randomness used by downstream consumers.Root Cause
In
pallets/drand/src/verifier.rs, theQuicknetVerifier::verifymethod returnsOk(true)based solely on the BLS pairing check. Therandomnessfield is never validated againstsha256(signature).The Fix
Add a second check in
QuicknetVerifier::verify: computesha256(signature)and compare it againstpulse.randomness. ReturnOk(false)on mismatch, which causeswrite_pulseto skip storing the forged pulse without erroring the extrinsic.Testing
Added
audit_probe_forged_randomness_rejectedwhich submits a valid drand signature paired with a forgedrandomness(32 bytes of 0x42). The test verifies that the pulse is NOT stored inPulsesandLastStoredRoundis not advanced, confirming the forged pulse was rejected.Type of Change
Checklist