Description:
The TokenDivider::nftToErc20Info
mapping keeps track of the address of the NFT contract and the corresponding ERC20Info
struct created when calling TokenDivider::divideNft
. This way, if a user wants to divide multiple NFTs from the same colleciton, the address will remain the same, and therefore the mapping will override the already stored information, causing a loss of all the details regarding the previous NFT divided.
Impact:
This vulnerability will severly break the protocol, as there there will be no track of the information regarding the NFTs from the same collection that have been divided before the last NFT. Information such as contract address and tokenId will be no longer available on-chain and will cause collision when trying to sell the corresponding ERC20 via the TokenDivider::sellErc20
function.
Tools Used:
Manual review
Proof of Concept:
Add the following test in TokenDividerTest.t.sol
. This test demostrates that when multiple users divide NFTs from the same collection, hence with the same contract address, the TokenDivider::getErc20InfoFromNft
function, which will retrieve information from TokenDivider::nftToErc20Info
mapping, will return a different value for erc20Address
before and after the division of the second NFT.
Recommended Mitigation:
It is recommended to modify the TokenDivider::nftToErc20Info
mapping in order to keep track of the tokenId for the NFT, along with its contract address.
ATTENTION: this change will need further integration with all the other functions in TokenDivider
. Updates to the mapping will now have to consider the tokenId, along with the contract address for the NFT. As an example, TokenDivider::divideNft
will be modified as follows:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.