A malicious buyer can set their amountPerRound variable very low, leading to a BuyLimitExceeded revert in the BuyerAgent::purchase function. This would prevent them from making any purchases while still collecting the royalty fees from sellers who list and relist their assets.
A malicious buyer can collect the royaltyFee without making any purchases by setting the amountPerRound variable very low in the BuyerAgent::purchase function. This will trigger a BuyLimitExceeded revert, preventing the attacker from spending any money while still gaining the royalty fee each time an asset is listed or relisted.
This is beacuse the transferRoyaltiesfunction is called in the Swan::listand Swan::relistfunction instead of Swan::purchase.
The automatic purchase will also revert be setting the amountPerRound low.
The revert BuyLimitExceeded-> https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/BuyerAgent.sol#L244
transferRoyalties call in Swan::list function-> https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/Swan.sol#L188
transferRoyalties call in Swan::relist function-> https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/Swan.sol#L252
The attacker can drain the funds of seller by collecting royaltyfee each time asset is listed and relisted, and still do not purchase any asset.
The malicious buyer then withdraw the royaltyfee, without even spending a penny he get money.
Manual Review
The following changes will transfer royalty to buyer only if the purchase is made.
Remove the 2 transferRoyalties calls from list and relist function.
transferRoyalties call in Swan::list function-> https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/Swan.sol#L188
transferRoyalties call in Swan::relist function-> https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/Swan.sol#L252
2.And add the call for transferRoyaltiesin the Swan::purchasefunction as given below:-
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.