You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OlaHamid - **Denial of Service (DoS) via Excessive Gas Consumption in warmUpSettlementState IN THE NounsAuctionHouseV2 AND NounsAuctionHouseV2.sol CONTRACTS **
#175
**Denial of Service (DoS) via Excessive Gas Consumption in warmUpSettlementState IN THE NounsAuctionHouseV2 AND NounsAuctionHouseV2.sol CONTRACTS **
Summary:
The warmUpSettlementState function in NounsAuctionHouseV2 AND NounsAuctionHouseV2.sol can be exploited to create a Denial of Service (DoS) condition by consuming excessive gas. This occurs when a large range of IDs is passed as parameters, causing the function to iterate over a significant number of elements. This can result in the gas required to execute the transaction exceeding the block gas limit, rendering the function unusable.
Vulnerability Details:
Location:
File: NounsAuctionHouseV2.sol AND NounsAuctionHouseV3.sol
The warmUpSettlementState function contains a for loop iterating from startId to endId. When endId - startId is excessively large, the gas required exceeds the block gas limit (~30M gas on Ethereum Mainnet), causing the transaction to fail.
This vulnerability can be exploited to disrupt the intended functionality of warming up settlement slots, potentially impacting auctions or related processes.
Proof of Concept (PoC):
copy and paste this in the NounAuctionHouseV3.t.sol A test was written to simulate a large range of settlement states being warmed up:
uint256 largeStartId =0;
uint256 largeEndId =20000; // Large range to simulate DoS attemptuint256 gasBefore =gasleft();
auction.warmUpSettlementState(largeStartId, largeEndId);
uint256 gasAfter =gasleft();
console.log("Gas used for large range:", gasBefore - gasAfter);
Gas used: 883,180,016, far exceeding the block gas limit.
Impact:
This vulnerability allows an attacker to disrupt the functionality of the warmUpSettlementState function by exploiting gas limitations, leading to a Denial of Service condition.
Recommendations: These are some of the recommendation to fix the vulnerability, Any or multiple of the following should be fine.
Restrict Range Size:
Introduce a check to limit the range (endId - startId) to a safe value that ensures gas usage remains within block gas limits:
+ error maxGasLimitError();+ // this can be flexible depending on the dev choise settings+ uint256 MAX_BATCH_SIZE = 5000;
function warmUpSettlementState(uint256 startId, uint256 endId) external {
+ require(endId - startId <= MAX_BATCH_SIZE, "Range too large");
for (uint256 i = startId; i < endId; ++i) {
// Skipping Nounder rewards, no need to warm up those slots since they are never used.
// this keyword continue, is weird...
// o think this next line is protecting from a DOS attack
if (i <= 1820 && i % 10 == 0) continue;
SettlementState storage settlementState = settlementHistory[i];
if (settlementState.blockTimestamp == 0) {
settlementState.blockTimestamp = 1;
settlementState.slotWarmedUp = true;
}
}
Implement a more stricter Batching:
Add Gas Safety Checks:
Monitor gas usage within the loop and break early if the remaining gas drops below a safe threshold:
+ error maxGasLimitError();+ //this can be flexible depending on the dev choise settings+ uint256 public constant SAFE_GAS_THRESHOLD = 20_000_000;
function warmUpSettlementState(uint256 startId, uint256 endId) external {
for (uint256 i = startId; i < endId; ++i) {
// Skipping Nounder rewards, no need to warm up those slots since they are never used.
// this keyword continue, is weird...
// o think this next line is protecting from a DOS attack
if (i <= 1820 && i % 10 == 0) continue;
SettlementState storage settlementState = settlementHistory[i];
if (settlementState.blockTimestamp == 0) {
settlementState.blockTimestamp = 1;
settlementState.slotWarmedUp = true;
}
+ if (gasleft() < SAFE_GAS_THRESHOLD) revert maxGasLimitError();
}
The text was updated successfully, but these errors were encountered:
sherlock-admin4
changed the title
Generous Peanut Platypus - **Denial of Service (DoS) via Excessive Gas Consumption in warmUpSettlementState IN THE NounsAuctionHouseV2 AND NounsAuctionHouseV2.sol CONTRACTS **
OlaHamid - **Denial of Service (DoS) via Excessive Gas Consumption in warmUpSettlementState IN THE NounsAuctionHouseV2 AND NounsAuctionHouseV2.sol CONTRACTS **
Dec 4, 2024
OlaHamid
Medium
**Denial of Service (DoS) via Excessive Gas Consumption in
warmUpSettlementState
IN THENounsAuctionHouseV2
ANDNounsAuctionHouseV2.sol
CONTRACTS **Summary:
The
warmUpSettlementState
function inNounsAuctionHouseV2
ANDNounsAuctionHouseV2.sol
can be exploited to create a Denial of Service (DoS) condition by consuming excessive gas. This occurs when a large range of IDs is passed as parameters, causing the function to iterate over a significant number of elements. This can result in the gas required to execute the transaction exceeding the block gas limit, rendering the function unusable.Vulnerability Details:
Location:
NounsAuctionHouseV2.sol
ANDNounsAuctionHouseV3.sol
Description:
warmUpSettlementState
function contains afor
loop iterating fromstartId
toendId
. WhenendId - startId
is excessively large, the gas required exceeds the block gas limit (~30M gas on Ethereum Mainnet), causing the transaction to fail.Proof of Concept (PoC):
NounAuctionHouseV3.t.sol
A test was written to simulate a large range of settlement states being warmed up:Impact:
warmUpSettlementState
function by exploiting gas limitations, leading to a Denial of Service condition.Recommendations: These are some of the recommendation to fix the vulnerability, Any or multiple of the following should be fine.
endId - startId
) to a safe value that ensures gas usage remains within block gas limits:Implement a more stricter Batching:
Add Gas Safety Checks:
The text was updated successfully, but these errors were encountered: