Pieces Protocol

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

Fake or Malicious ERC20 Tokens in sellErc20

Summary

The contract does not verify the legitimacy of ERC20 tokens before interacting with them, allowing malicious sellers to introduce fake or malicious tokens. This could lead to misleading users or executing unexpected behaviors during token transfers.

Vulnerability Details

Impact

1. Security Risks: Users might interact with tokens that are not what they seem, potentially leading to theft or loss.
2. Reputation Damage: Trust in the platform could be undermined if users encounter issues with token interactions.
3. User Confusion: If fake tokens are listed, users might mistakenly buy or interact with them, leading to poor user experience.

Tools Used

Manual Review

Recommendations

Add token validation checks before any ERC20 interaction:
Code Snippet:
```solidity
function validateToken(address token) internal view returns (bool) {
IERC20 erc20 = IERC20(token);
try erc20.balanceOf(address(this)) returns (uint256) {
return true;
} catch {
return false;
}
}
function sellErc20(address nftPegged, uint256 price, uint256 amount) external {
// ... existing checks ...
require(validateToken(tokenInfo.erc20Address), "Invalid or malicious token");
// ... rest of the function ...
}
```
Updates

Lead Judging Commences

fishy Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Appeal created

osuolale Submitter
8 months ago
fishy Lead Judge 8 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Lack of token access control chekcs

Any person can mint the ERC20 token generated in representation of the NFT

Support

FAQs

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