Dria

Swan
NFTHardhat
21,000 USDC
View results
Submission Details
Severity: medium
Valid

A malicious user will spam by listing for multiple buyer agents with zero `_price`

Summary

An attacker will continuosly list for the buyer agents with zero _price. As their is no royaltyFee for listing if priceis zero. which allows the attacker to target a particular buyer and list max possible assets to the buyer in a round. Because of which no other genuine lister can list the buyer. Same attacker can target as many buyer as they want.

Vulnerability Details

Code:

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

Currently in the list() , the lister should not have to pay any buyerFee, driaFee if the _priceis zero while listing. Currently the fee is calculated and transferred in the transferRoyalties() function after listing the asset.

function transferRoyalties(AssetListing storage asset) internal {
// calculate fees
@>> // @audit buyerFee, driaFee will be zero if asset.price = 0
@>> uint256 buyerFee = (asset.price * asset.royaltyFee) / 100;
@>> uint256 driaFee = (buyerFee * getCurrentMarketParameters().platformFee) / 100;
// 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);
}

Considering the swan protocol will deploy on EVM L2 chains like base, the gas fee is near to negligible. So the attack is economically fisible.

Scenario:

Suppose Alice has buyerAgent contract, Bob is lister, we also have other listeres like Harry, Alok

  1. Alice will create buyer agent and he is in sell phase now to accept listings

  2. Bob who is malicious actor will list maxAssetCount for that buyerAgent in that round. Due to which other Genuine listers cannot list Alice. attacker can eventually create monopoly by spamming listing

  3. Genuine listers will be impacted due to this and they can't participate anymore

Impact

Genuine lister's will be highly impacted and can't able to participate to list for buyer Agents

Tools Used

Manual Inspection

Recommendations

  • To fix this issue we have to add a check, which essentially reverts if a lister tries to list with zero _price

function list(string calldata _name, string calldata _symbol, bytes calldata _desc, uint256 _price, address _buyer)
external
{
require(_price != 0, "listing with zero price is not allowed");
...
}
  • Also add a max Listing count for a particular seller, buyer and round.

Updates

Lead Judging Commences

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

DOS the buyer / Lack of minimal amount of listing price

Appeal created

0xmax1mus Submitter
8 months ago
inallhonesty Lead Judge
8 months ago
inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

DOS the buyer / Lack of minimal amount of listing price

Support

FAQs

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