The Standard

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

[L-1] Transactions that distribute fees can be frontrun

Pending token positions can be consolidated after 1 day of submission. This is the case for both the governance token TST and EUROs positions. It seems to be a measure to prevent sandwich attacks on liquidations. However, when distributing fees they are only distributed for TST holders and pending stakes are taken into account as well. This means that a user that has governance tokens can deposit a large amount of them in a transaction just before a distributeFees() transaction and take a larger portion of the rewards. The user can take them out only after 1 day has passed and the position is consolidated, so this is somewhat mitigated. After, the user can then out his TST to use it in other parts of the protocol, while waiting for the next call to distribute fees.

https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L182

function distributeFees(uint256 _amount) external onlyManager {
uint256 tstTotal = getTstTotal(); // @audit this is ALL TST, so positions + pendingStakes
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++) {
pendingStakes[i].EUROs += _amount * pendingStakes[i].TST / tstTotal;
}
}
}

The feasibility of this attack depends on how governance tokens TST work in other parts of the larger protocol. Investigating further is out of scope for this audit. In any case, a user will have to keep their TST tokens locked in pendingStakes for at least a day, so maybe it is a good idea to not take pending TST stakes into account for the distributeFees() transaction to avoid the above mentioned attack.

Updates

Lead Judging Commences

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

frontrun-distrubutefees

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

frontrun-feedist-low

Support

FAQs

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