Description:
Once the NFT has been divided in multiple fractions, represented by a given amount of ERC20 (which should be fixed), an attacker could call the ERC20ToGenerateNftFraccion::mint
function to generate an arbitrary amount of that specific ERC20 token.
Impact:
The unauthorized minting of ERC20 tokens causes an increase in the amount of "pieces" of a particular NFT available in the market, therefore leading to a break in the protocol core logic. Even though the state variable in TokenDivider
are not affected by this unauthorized minting, the user should not be able to mint ERC20 tokens outside the scope of TokenDivider
.
Tools Used:
Manual review
Proof of Concept:
Add the following test in TokenDividerTest.t.sol
. This test demonstrates how the user can actually mint more ERC20 tokens than the amount established when calling the TokenDivider::divideNft
function. The test is an expansion of the already existing TokenDividerTest::testDivideNft
test.
Recommended Mitigation:
It is recommended to limit the minting of new ERC20 tokens to TokenDivider
contract, which should be intended as the only authorized minter for those tokens. This can be achieved by creating a modifier that checks if the msg.sender
that calls the ERC20ToGenerateNftFraccion::mint
function is the TokenDivider
contract. Otherwise it will revert with a custom error.
Below is the code implementation to be added in the ERC20ToGenerateNftFraccion::mint
, including the _tokenDivider
parameter to be passed in the constructor.
The correct implementation can be checked by running the testUnauthorizedMintingOfERC20Tokens
test again. This time the test should fail with the ERC20ToGenerateNftFraccion__UnauthorizedMinter
custom error.
Any person can mint the ERC20 token generated in representation of the NFT
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.