The smart contract DSCEngine.sol
contains a Denial-of-Service (DoS) vulnerability that allows an attacker to disrupt normal contract operations by submitting a large number of unique collateral tokens. The vulnerability arises from the excessive gas consumption during the execution of the getAccountCollateralValue
function, which iterates through deposited collateral tokens and fetches their USD values to calculate the total collateral value. When an attacker deposits a substantial number of different collateral tokens, the function consumes more gas than the block limit, causing it to become unresponsive. As a result, legitimate users trying to interact with the contract face a denial of service, rendering essential functionalities unusable.
The getAccountCollateralValue
function loops through each collateral token deposited by a user, retrieves their corresponding USD values using the getUsdValue
function, and accumulates the total collateral value in USD. However, the function lacks proper gas checks and constraints on the number of iterations, making it susceptible to abuse.
Lack proper gas checks:
A DoS attack on the getAccountCollateralValue
function can severely impact the contract's functionality. If an attacker deliberately deposits a large number of collateral tokens, the function's gas consumption can surpass the gas block limit. As a result, the function will be unable to complete its execution, leading to a denial of service for other users trying to interact with the contract.
VS code
Manual review
One potential fix would be to add a gas check after each iteration for example:
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.