Dria

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

Malacious behaviour by the buyer

Summary :

When the user create a listing to sell his assets using the function [list()](https://github.com/Cyfrin/2024-10-swan-dria/blob/main/contracts/swan/Swan.sol#L157-L192)
he have to give royalty fee to the buyer which is calculated by the function transferRoyalties() and send to the buyer as soon as the list is made.

Vulnerability Details :

In the below code :

the buyer's portion of royalty is send when the listing is created before the purchase is even made by the buyer.
the asset.royaltyFee is set by the buyer which ranges between [1,100].

function transferRoyalties(AssetListing storage asset) internal {
// calculate fees
uint256 buyerFee = (asset.price * asset.royaltyFee) / 100;
uint256 driaFee = (buyerFee * getCurrentMarketParameters().platformFee) / 100; //!decimal precision
// first, Swan receives the entire fee from seller
// this allows only one approval from the seller's side
token.transferFrom(asset.seller, address(this), buyerFee);
// send the buyer's portion to them
token.transfer(asset.buyer, buyerFee - driaFee);
// then it sends the remaining to Swan owner
token.transfer(owner(), driaFee);
}

Impact :

The malacious buyer will get the royalty fee without spending any of it's token and the seller have to relist the asset and have to give royalty fee again to another buyer.

Tools Used :

Manual review

Recommendations :

Transfer the buyer's portion of royality only if the purchase is made by the buyer otherwise transfer whole royalty as dreafee if assets is not sold.

Updates

Lead Judging Commences

inallhonesty Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Appeal created

ashutoshsb Submitter
9 months ago
inallhonesty Lead Judge
9 months ago
inallhonesty Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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