getRandomTokenIdFromFund yields wrong probabilities for ERC1155
The random token selection function for ERC1155 vaults ignores the quantity of each token deposited, giving each token ID an equal chance instead of weighting by quantity. An attacker could exploit this to preferentially redeem more valuable NFTs.
NFTX contest
Originally disclosed on Code4rena
NFTXVaultUpgradeable.getRandomTokenIdFromFund does not work with ERC1155 as it does not take the deposited quantity1155 into account.
Assume tokenId0 has a count of 100, and tokenId1 has a count of 1. Then getRandomId would have a pseudo-random 1:1 chance for token 0 and 1 when in reality it should be 100:1.
This might make it easier for an attacker to redeem more valuable NFTs as the probabilities are off.
Recommend taking the quantities of each token into account (quantity1155) which probably requires a design change as it is currently hard to do without iterating over all tokens.
Marking this as high risk as an attacker can weed out high-value NFTs from a vault putting other users funds at risk
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
Likely the random selection function does not weight each token ID by its deposited quantity, so each ID is equally likely to be chosen.
Impact
An attacker could more easily redeem high-value NFTs from a vault, putting other users' funds at risk.
What the attacker needed
ERC1155 tokens in a vault; attacker can redeem from the vault
The fix
The function should be changed to take each token's deposited quantity into account when selecting randomly, though this likely requires a design change.
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.
When you put NFTs into a vault, the vault sometimes gives you a random one back. This report says that for a certain type of NFT (ERC1155), the random pick treats every token ID equally, even if you deposited 100 of one and only 1 of another. That means someone could game the system to get the rare or valuable ones more often than they should.
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.