Both block.prevrandao and block.timestamp are not reliably source of randonness
0x539.eth Follow with 0xSecuri, 0xloophole and 13 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-06-boost-aa-wallet-judging/issues/106
The protocol has acknowledged this issue.
Found by
0x539.eth, 0xSecuri, 0xloophole, 4b, Atharv, Japy69, Okazaki, Pheonix, ctf_sec, denzi_, ge6a, haxagon, oxelmiguel, pwning_dev, sakshamguruji, tinnohofficial
Summary
Both block.prevrandao and block.timestamp are not reliably source of randonness
Vulnerability Detail
In the ERC20Incentive.sol,
function drawRaffle() external override onlyOwner {
if (strategy != Strategy.RAFFLE) revert BoostError.Unauthorized();
LibPRNG.PRNG memory _prng = LibPRNG.PRNG({state: block.prevrandao + block.timestamp});
address winnerAddress = entries[_prng.next() % entries.length];
asset.safeTransfer(winnerAddress, reward);
emit Claimed(winnerAddress, abi.encodePacked(asset, winnerAddress, reward));
}
the code use block.prevrandao and block.timestamp as source of randoness to determine who is lucky to win the raffle.
However, both op code are not good source of randonness.
https://eips.ethereum.org/EIPS/eip-4399
Security Considerations The PREVRANDAO (0x44) opcode in PoS Ethereum (based on the beacon chain RANDAO implementation) is a source of randomness with different properties to the randomness supplied by BLOCKHASH (0x40) or DIFFICULTY (0x44) opcodes in the PoW network.
Biasability The beacon chain RANDAO implementation gives every block proposer 1 bit of influence power per slot. Proposer may deliberately refuse to propose a block on the opportunity cost of proposer and transaction fees to prevent beacon chain randomness (a RANDAO mix) from being updated in a particular slot.
Impact
Miner can manipulate the block.prevrandao and block.timestamp to let specific address win the raffle
Code Snippet
Tool used
Manual Review
Recommendation
change randon generate method (can use chainlink VRF, etc...)
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity smart contracts bug in Boost Core Incentive Protocol. Sherlock made it public on 2 October 2024. Found in the 426 audit contest (finding M-1), also found by 15 other wardens.
About Smart contracts
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.