CoreCollection: Starting index is pseudo-randomly generated, allowing for gameable NFT launches
The starting index for NFT metadata was derived from the current block number, which is predictable. An attacker could compute future starting indexes and scrape metadata to snipe rare NFTs.
Submitted by hickuphh3
In Paradigm’s article “A Guide to Designing Effective NFT Launches”, one of the desirable properties of an NFT launch is unexploitable fairness: Launches must have true randomness to ensure that predatory users cannot snipe the rarest items at the expense of less sophisticated users.
It is therefore highly recommended to find a good source of entropy for the generation of the starting index. The block.number isn’t random at all; it only incrementally increases, allowing anyone to easily compute the starting indexes of the next 10,000 blocks for instance.
contract FortuneTeller {
function predictStartingIndexes(uint256 maxSupply, uint256 numBlocks)
external
view
returns
(uint256[] memory startingIndexes) {
startingIndexes = new uint[](numBlocks);
for (uint256 i = 0; i < numBlocks; ++i) {
startingIndexes[i] = (uint256(
keccak256(abi.encodePacked("CoreCollection", block.number + i))
) % maxSupply) +
1;
}
}
}
Coupled with the fact that the _baseUri is set upon initialization, the metadata could be scrapped beforehand to determine the rare NFTs.
Thus, NFT mints can be gamed / exploited.
Recommended Mitigation Steps
Consider exploring the use of commit-reveal schemes (eg. blockhash of a future block, less gameable but not foolproof) or VRFs.
sofianeOuafir (Joyn) acknowledged and commented:
This is a known issue and for now, we’re not going to solve it
deluca-mike (judge) commented:
I’d reconsider not completely it, but rather doing
keccak256(abi.encodePacked("CoreCollection", blockhash(block.number - 1), block.coinbase, msg.sender, i))so at least there is a much smaller set of users that will know what the previous blockhash and the current miner will be by the time the tx mines, and it will be salted with the sender.It’s not perfect, but it’s significantly better.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The starting index was generated using `block.number`, which is predictable and not random.
Impact
An attacker could predict the starting index and snipe rare NFTs, undermining fairness.
What the attacker needed
Ability to compute block hashes; access to NFT metadata
The fix
The project acknowledged the issue but chose not to fix it; the judge suggested using a combination of blockhash, coinbase, sender, and index to improve randomness.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In many NFT projects, the order of items is shuffled by a starting index. If that index is based on something predictable like the current block number, anyone can calculate what it will be ahead of time. This lets someone buy the rarest items before others, which is unfair.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.