The Standard

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

Unbounded pendingStakes could result in DOS in LiquidationPool

Summary

The pendingStakes array in the LiquidationPool contract is unbounded, which could lead to a potential Denial of Service (DoS) vulnerability. The array is utilized in functions like consolidatePendingStakes and distributeFees, both of which are called within critical functions (increasePosition, decreasePosition, distributeAssets).

Vulnerability Details

The consolidatePendingStakes function iterates over the entire pendingStakes array, and the same goes for the distributeFees function. A malicious user could repeatedly increase their position, causing the pendingStakes array to grow without bounds. This unbounded growth could lead to excessive gas consumption and result in a DoS attack.

function consolidatePendingStakes() private {
uint256 deadline = block.timestamp - 1 days;
for (int256 i = 0; uint256(i) < pendingStakes.length; i++) { //@audit dos
PendingStake memory _stake = pendingStakes[uint256(i)];
if (_stake.createdAt < deadline) {
positions[_stake.holder].holder = _stake.holder;
positions[_stake.holder].TST += _stake.TST;
positions[_stake.holder].EUROs += _stake.EUROs;
deletePendingStake(uint256(i));
// pause iterating on loop because there has been a deletion. "next" item has same index
i--;
}
}
}
function distributeFees(uint256 _amount) external onlyManager {
uint256 tstTotal = getTstTotal();
if (tstTotal > 0) {
IERC20(EUROs).safeTransferFrom(msg.sender, address(this), _amount);
for (uint256 i = 0; i < holders.length; i++) {
address _holder = holders[i];
positions[_holder].EUROs += _amount * positions[_holder].TST / tstTotal;
}
for (uint256 i = 0; i < pendingStakes.length; i++) { //@audit dos
pendingStakes[i].EUROs += _amount * pendingStakes[i].TST / tstTotal;
}
}
}

Impact

The potential impact is an increased risk of insolvency and a DoS attack on the LiquidationPool contract due to unbounded growth of the pendingStakes array.

Tools Used

Manual Review

Recommendations

It is recommended to add a minimum amount requirement for increasing positions to mitigate the risk of unbounded growth of the pendingStakes array. Implementing a minimum increase position amount would discourage malicious users from causing excessive growth and reduce the risk of a DoS attack.

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.