Dria

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

Swan.sol:transferRoyalties function has many unchecked return values

Summary

transferRoyalties function includes three calls to the transferFrom and transfer functions of an ERC20 token, but it does not check whether these calls return true. In the ERC20 standard, transfer and transferFrom return a boolean indicating whether the operation was successful. Failure to check these return values can lead to unexpected behavior if any of these transfers fail silently.

Vulnerability Details

The following code lines contain unchecked return values:

token.transferFrom(asset.seller, address(this), buyerFee);
token.transfer(asset.buyer, buyerFee - driaFee);
token.transfer(owner(), driaFee);

Impact

If any of these transfers fail:

  • Funds might not be properly distributed, leaving some parties without their expected funds.

  • The contract might continue with invalid state assumptions, potentially leading to accounting inconsistencies.

  • Users expecting funds may be financially impacted, reducing the reliability of the contract.

Tools Used

  • Manual code reading

Recommendations

Check the return value of each transferFrom and transfer call and handle any failures appropriately.

require(token.transferFrom(asset.seller, address(this), buyerFee), "Transfer from seller failed");
require(token.transfer(asset.buyer, buyerFee - driaFee), "Transfer to buyer failed");
require(token.transfer(owner(), driaFee), "Transfer to owner failed");

OR

(bool success1) = token.transferFrom(asset.seller, address(this), buyerFee);
require(success1, "Transfer from seller failed");
// Send the buyer's portion to them
(bool success2) = token.transfer(asset.buyer, buyerFee - driaFee);
require(success2, "Transfer to buyer failed");
// Send the remaining portion to Swan's owner
(bool success3) = token.transfer(owner(), driaFee);
require(success3, "Transfer to owner failed");

Severity

Medium – This issue does not directly impact security but can lead to significant financial inconsistencies and operational issues if left unaddressed.

Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

[KNOWN] - Low-35 Unsafe use of transfer()/transferFrom() with IERC20

Support

FAQs

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