The Swan contract's list function vulnerable to a Denial of Service (DoS) attack on asset listings. This vulnerability arises due to unrestricted listing of assets by malicious actors who can manipulate contract state, reaching the asset limit per buyer or creating unintended congestion. This can disrupt functionality for legitimate users by blocking new assets from being listed, ultimately affecting the performance and usability of the platform.
In the Swan contract, the list function allows a seller to create and list a new asset for a buyer, with a limit on the number of assets per buyer. However, there are no checks in place to prevent malicious actors from repeatedly listing assets for a specific buyer, which could fill up the allowed asset count per buyer for a particular round. By exploiting this, an attacker could effectively prevent legitimate assets from being listed, causing a Denial of Service.
The following code snippet illustrates the list function, which lacks restrictive checks on who can list an asset for a particular buyer:
An attacker could deploy a script or contract that continually calls the list function, specifying a target buyer's address. By hitting the asset limit per round for this buyer, the attacker prevents legitimate assets from being listed.
Steps:
Deploy the Swan contract and set up an instance of a BuyerAgent for testing.
Set the maxAssetCount parameter for buyers.
Execute a script or Hardhat test that simulates multiple list transactions with the same buyer address until the maximum asset count is reached.
Observe that once the limit is hit, legitimate listing requests for that buyer are denied due to the AssetLimitExceeded revert.
The following Hardhat test demonstrates the DoS attack:
Running the above test should show that once the attacker has listed assets up to the limit, any further attempt to list assets for that buyer, including legitimate ones, is denied with the message "AssetLimitExceeded". This effectively locks out legitimate users from listing assets.
This vulnerability can lead to a Denial of Service on the asset listing functionality for specific buyers. Legitimate users may be unable to list new assets, which degrades user experience, blocks potential revenue streams, and harms the protocol’s integrity. This can be especially damaging in high-demand rounds where timely listings are critical.
Manual review.
Restrict Listing Permissions: Require that only certain verified actors or whitelisted accounts can call the list function for a buyer.
Dynamic Asset Count Adjustment: Allow for dynamic adjustments of maxAssetCount to prevent attackers from easily predicting the limit.
Cooldown Mechanism: Implement a cooldown period between consecutive listings for the same buyer to make mass listing harder for attackers.
Access Control: Require only the owner or an approved address to list assets on behalf of a buyer to mitigate unauthorized listing spam.
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.