Inside of EntropyGenerator smart contract, there are two functions that are used to get entopies: getEntropy() and getNextEntropy(). The problem is that they check for incorrect max slot index at the start of the function which may result in an unexpected behavior.
Proof of Concept
There are only 770 slots designed to store 78 digit numbers (with 13 concatenated entropies in them). And the first slot has always index 0. That basically means that the last slot will have the index of 769. But in the current implementation of EntropyGenerator, it checks for 770 instead of 769:
function getEntropy(
uint256 slotIndex,
uint256 numberIndex
) private view returns (uint256) {
require(slotIndex <= maxSlotIndex, 'Slot index out of bounds.');
This check basically allows to get entropies for more slots than there are in existence and it can potentially result in an unexpected behavior and DoS.
Tools Used
Manual review.
Recommended Mitigation Steps
Replace the check above on this:
require(currentSlotIndex < maxSlotIndex, 'Max slot index reached.');
Lines of code
https://github.com/code-423n4/2024-07-traitforge/blob/main/contracts/EntropyGenerator/EntropyGenerator.sol#L168 https://github.com/code-423n4/2024-07-traitforge/blob/main/contracts/EntropyGenerator/EntropyGenerator.sol#L102
Vulnerability details
Impact
Inside of
EntropyGenerator
smart contract, there are two functions that are used to get entopies:getEntropy()
andgetNextEntropy()
. The problem is that they check for incorrect max slot index at the start of the function which may result in an unexpected behavior.Proof of Concept
There are only 770 slots designed to store 78 digit numbers (with 13 concatenated entropies in them). And the first slot has always index 0. That basically means that the last slot will have the index of 769. But in the current implementation of
EntropyGenerator
, it checks for 770 instead of 769:https://github.com/code-423n4/2024-07-traitforge/blob/main/contracts/EntropyGenerator/EntropyGenerator.sol#L102
https://github.com/code-423n4/2024-07-traitforge/blob/main/contracts/EntropyGenerator/EntropyGenerator.sol#L168
https://github.com/code-423n4/2024-07-traitforge/blob/main/contracts/EntropyGenerator/EntropyGenerator.sol#L17
This check basically allows to get entropies for more slots than there are in existence and it can potentially result in an unexpected behavior and DoS.
Tools Used
Manual review.
Recommended Mitigation Steps
Replace the check above on this:
Assessed type
Other