Distribution of fees can be front-run by any attacker on-chain just by jumping on the protocol for a few seconds thereby taking as many rewards if not all rewards meant to be distributed to legitimate users who have been a part of the protocol for a long period.
This vulnerability exists across several parts of the codebase's logic for rewarding users. The issue becomes prone to frontruns because even pending stakers who haven't been staked earn rewards just as normal users who have been staked a long time. So there's no real incentive to stake for a long time.
As noted in the code, anyone can trigger the distributeAssets
function of the LiquidationPoolManager to begin the process of the attack. A bot can be up to monitor when _feesForPool > 0
and kick off the attack then deposit a huge amount of TST and run distributeFees
of the manager contract or wait for somebody to run it then front run with their deposit. A flashloan can be used for max profit. TST stakes in the pool doesnt have to be 0, just low enough for him
to get max rewards.
Since the EUROs position of pendingStakes
gets included in the fee distribution, a staker who joined at least one position above the txn to distribute fees will earn rewards and just proceed to quit the system afterwards then the process repeats.
The vulnerability has already highlighted the impact but in simple terms, legitimate users will get next to nothing compared to a bot who has a massive stake and then quit the system after the realized profit. Even if the team advises users to have both EUROs and TST staked, we don't believe each user has the same buying power of funds acquired by flashloans.
Manual review
Some recommendations we have to remediate this issue:
Perhaps don't let the distributeFees
of the LiquidationPoolManager
be accessible to everyone. This will fix one of the issue but still be prone to frontruns of the actual txn.
Enforce a minimum stake period e.g. 1 day or more and remove pendingStakes
from the rewards. Keep rewards to users who are actually staked.
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.