The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: high
Valid

DoS via Loops Iterating Over Large State Arrays

Summary

User can create a huge amount of addresses and with LiquidationPool::increasePosition() push an enormous amount of stakes in the storage pendingStakes variable.

Vulnerability Details

LiquidationPool contract heavily depends on pendingStakes.length since pendingStakes storage variable iterates over it will lead to the DoS of the entire protocol.
Even though the protocol has functionality to remove pendingStake it also depends on the loop and there may not be enough gas in the transaction to remove it from the storage variable either.

File: contracts/LiquidationPool.sol
59: for (uint256 i = 0; i < pendingStakes.length; i++) {
/// @audit state `pendingStakes[]` is `push()`ed and may grow too large to iterate over. | 140: pendingStakes.push(PendingStake(msg.sender, block.timestamp, _tstVal, _eurosVal));
74: for (uint256 i = 0; i < pendingStakes.length; i++) {
/// @audit state `pendingStakes[]` is `push()`ed and may grow too large to iterate over. | 140: pendingStakes.push(PendingStake(msg.sender, block.timestamp, _tstVal, _eurosVal));
106: for (uint256 i = _i; i < pendingStakes.length - 1; i++) {
/// @audit state `pendingStakes[]` is `push()`ed and may grow too large to iterate over. | 140: pendingStakes.push(PendingStake(msg.sender, block.timestamp, _tstVal, _eurosVal));
121: for (int256 i = 0; uint256(i) < pendingStakes.length; i++) {
/// @audit state `pendingStakes[]` is `push()`ed and may grow too large to iterate over. | 140: pendingStakes.push(PendingStake(msg.sender, block.timestamp, _tstVal, _eurosVal));
190: for (uint256 i = 0; i < pendingStakes.length; i++) {

Tools Used

VsCode

Recommendations

Add length limitation to pendingStakes

Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

pendingstake-dos

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

pendingstake-high

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.