RandomizerNXT produce predictable token hashes before hand #217
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-1901
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/RandomizerNXT.sol#L55-L59
Vulnerability details
Impact
Medium impact
Bug explanation
Trying to get random values on-chain is not possible because the values can be predicted.
The randomizer NXT contract gets "random" values from the XRandoms contract. This other contract provides the "randomness" the following ways:
The values that this contract provides are not really random. Any user can predict the output hash of the upcoming NFT before minting it and waiting for a certain situation that he can benefit from.
Proof of Concept
With the following function in a custom contract, the user can check the output hash that the next NFT will have.
So he can program a bot that tracks the output hash that the NFT will have at any moment. And eventually, when the hash matches a condition that the user can get benefit from, execute the NFT mint.
The following test demonstraits that the predicted hash matches the hash that the next NFT gets.
Tools Used
Manual review
Recommended Mitigation Steps
Use other methods to get random data off-chain. For example chainlink VRF is a perfect example. It provides random numbers that are 100% unpredictable so users can not get more beneficial hashes.
Assessed type
Other
The text was updated successfully, but these errors were encountered: