The Standard

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

No minimal amount of increasing position

Summary

There is no minimum amount by which user can increase a position. User could increase position even on 1.

Vulnerability Details

When user want increase position, he call LiquidationPool.increasePosition() and this function push struct with information about new future position in to pendingStakes array. User could add big amount of new pending stakes, in pendingStakes array become so big, that cause out of gas, when new user will call increasePosition(), because this function call internal function consolidatePendingStakes, which iterate through pendingStakes array.

function increasePosition(uint256 _tstVal, uint256 _eurosVal) external {
require(_tstVal > 0 || _eurosVal > 0);
consolidatePendingStakes(); // <-------------------
ILiquidationPoolManager(manager).distributeFees();
if (_tstVal > 0) IERC20(TST).safeTransferFrom(msg.sender, address(this), _tstVal);
if (_eurosVal > 0) IERC20(EUROs).safeTransferFrom(msg.sender, address(this), _eurosVal);
pendingStakes.push(PendingStake(msg.sender, block.timestamp, _tstVal, _eurosVal)); // <------------------
addUniqueHolder(msg.sender);
}
function consolidatePendingStakes() private {
uint256 deadline = block.timestamp - 1 days;
for (int256 i = 0; uint256(i) < pendingStakes.length; i++) {
...
}
}

Impact

This could cause a problem throughout contract if there are a high number of pending stakes. Next user could not increase own position, because tx will revert with reason out of gas.

Tools Used

Manual review

Recommendations

Add 2 variables, which will contain min value of tst and euros for increasing position.

Updates

Lead Judging Commences

hrishibhat Lead Judge almost 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

pendingstake-dos

hrishibhat Lead Judge almost 2 years 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.

Give us feedback!