The _transferPlots
function in the MarketplaceFacet
contract is susceptible to a Denial of Service (DoS) attack due to its unbounded iteration over an array of plot IDs. An attacker could exploit this by submitting a transaction with an extremely large array, causing the transaction to consume excessive gas and potentially exceeding the block gas limit. This would result in the transaction failing and could prevent other users from interacting with the contract.
The vulnerability lies in the following code snippet from the _transferPlots
function:
The loop iterates over the ids
array, which contains the IDs of the plots to be transferred. If the length of this array is very large, the loop will execute many times, consuming a significant amount of gas.
A successful DoS attack could have several negative consequences:
Disruption of Service: Legitimate users would be unable to interact with the MarketplaceFacet
contract, preventing them from buying, selling, or transferring plots.
Financial Losses: If the DoS attack occurs during a critical period, such as an auction or a sale, users could miss out on opportunities to participate, leading to potential financial losses.
Reputation Damage: A successful DoS attack could damage the reputation of the Beanstalk project, leading to a loss of trust from users and investors.
Manual code review
Solidity static analysis tools
To mitigate this vulnerability, consider the following recommendations:
Limit the Number of Plots per Transaction: Introduce a maximum limit on the number of plot IDs that can be included in the ids
array. This would restrict the maximum gas consumption of the _transferPlots
function and prevent attackers from creating excessively large transactions.
Batch Processing: Instead of processing all plot transfers in a single transaction, split them into smaller batches. This would distribute the gas consumption across multiple transactions, reducing the risk of exceeding the block gas limit.
Gas Optimization: Explore ways to optimize the gas consumption of the plot transfer logic within the loop. This could involve using more efficient data structures or algorithms to reduce the overall gas cost of the function.
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.