Pieces Protocol

First Flight #32
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: high
Valid

[L-1] Insufficient Access Check Allows User Transfer Theirown ERC20ToGenerateNftFraccion Tokens To Other Accounts

Summary

User is able to transfer the ERC20ToGenerateNftFraccion tokens to another account directly.

Vulnerability Details

Add following test case to TokenDividerTest.t.sol:

function testNftFraccionContract() public nftDivided{
ERC20ToGenerateNftFraccion erc20Mock = ERC20ToGenerateNftFraccion(tokenDivider.getErc20InfoFromNft(address(erc721Mock)).erc20Address);
vm.startPrank(USER);
erc20Mock.transfer(address(USER2), AMOUNT);
vm.stopPrank();
assertEq(tokenDivider.getBalanceOf(USER, address(erc20Mock)), AMOUNT);
assertEq(erc20Mock.balanceOf(address(USER)), 0);
vm.startPrank(USER);
erc20Mock.approve(address(tokenDivider), AMOUNT);
tokenDivider.claimNft(address(erc721Mock));
vm.stopPrank();
}

Impact

As a result, the real token balance is lower than the records in TokenDivider.balances. Then, the user lost control to their assets.

Tools Used

Foundry

Recommendations

Only allow the TokenDivider contract to transfer the ERC20ToGenerateNftFraccion tokens to other accounts.

Updates

Lead Judging Commences

fishy Lead Judge 5 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Wrong nft collection handling

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.