Dria

Swan
NFTHardhat
21,000 USDC
View results
Submission Details
Severity: low
Invalid

Wrong error message in relist()::Swan.sol

Summary

Wrong error message in relist()::Swan.sol line 234.

https://github.com/Cyfrin/2024-10-swan-dria/blob/main/contracts/swan/Swan.sol#L234

Vulnerability Details

// buyer must not have more than `maxAssetCount` many assets
uint256 count = assetsPerBuyerRound[_buyer][round].length;
if (count >= getCurrentMarketParameters().maxAssetCount) {
revert AssetLimitExceeded(count);
}

==> error AssetLimitExceeded is supposed to show the limit to inform the end user of the actual AssetLimit to not exceed, instead this code gives the count, which doesn't indicate at all how to correct the transaction to not revert again.
At each try from the end user, an error message will pop a different value as the "supposed limit to not exceed" being in fact the count which won't help the end user, at contrary it will misinform him.

The error AssetLimitExceeded is supposed to be as follow:

/// @notice Asset count limit exceeded for this round
error AssetLimitExceeded(uint256 limit);

https://github.com/Cyfrin/2024-10-swan-dria/blob/main/contracts/swan/Swan.sol#L33-L34

Impact

Error messages are there to lead the end user and/or the off chain Dapp connected to the smart contract.
A wrong error message could mislead the end user trying to figure out why his transaction failed.
The off chain Dapps used by the end user will also be impacted if they give back wrong informations like a wrong limit.

Tools Used

Github, Manual review.

Recommendations

Replace count at line 234 with getCurrentMarketParameters().maxAssetCount instead :

revert AssetLimitExceeded(getCurrentMarketParameters().maxAssetCount);

=>getCurrentMarketParameters().maxAssetCount is the limit.
Otherwise the end user will think that the actual count is the limit, he will never have
the information of what the AssetLimit (or maxAssetCount) is and will be mislead by the error message.

Updates

Lead Judging Commences

inallhonesty Lead Judge 8 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Wrong error message in relist()::Swan.sol

Appeal created

inallhonesty Lead Judge
7 months ago
inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Wrong error message in relist()::Swan.sol

Support

FAQs

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