Pieces Protocol

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

Missing zero price check in sellErc20()

Summary

There is no validation check in sellErc20 function to ensure that the price parameter is greater than zero.

Vulnerability Details

A zero price could allow a user to create a sell order where NFT are given away for free.

function sellErc20(address nftPegged, uint256 price,uint256 amount) external {
if(nftPegged == address(0)) {
revert TokenDivider__NftAddressIsZero();
}
if( amount == 0) {
revert TokenDivider__AmountCantBeZero();
}
// @ Audit missing check for zero price
ERC20Info memory tokenInfo = nftToErc20Info[nftPegged];
if(balances[msg.sender][tokenInfo.erc20Address] < amount) {
revert TokenDivider__InsuficientBalance();
}
balances[msg.sender][tokenInfo.erc20Address] -= amount;
s_userToSellOrders[msg.sender].push(
SellOrder({
seller: msg.sender,
erc20Address: tokenInfo.erc20Address,
price: price,
amount: amount
})
);
emit OrderPublished(amount,msg.sender, nftPegged);
IERC20(tokenInfo.erc20Address).transferFrom(msg.sender,address(this), amount);
}

Impact

This could lead to unintended or malicious sell orders that harm the marketplace's integrity.

Tools Used

Manual review

Recommendations

Add a check to prevent free sell orders.

Consistent Validation for nftPegged and amount:

Use the same style of validation for nftPegged and amount to maintain consistency

if(price < 1) {
revert TokenDivider__IncorrecPrice();
}
Updates

Lead Judging Commences

fishy Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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