Front run `distributeRewards()` can steal the newly added rewards
The reward distribution mechanism allows an attacker to deposit a large amount of tokens just before a reward distribution, capture a disproportionate share of the newly added rewards, and then withdraw immediately after. This is possible because each distribution causes a sudden increase in pointsPerShare, which the attacker can exploit.
Source: https://github.com/sherlock-audit/2022-10-merit-circle-judging/issues/106
Found by
WATCHPUG, hickuphh3, hyh
Summary
A surge of pointsPerShare on each distributeRewards() call can be used by the attacker to steal part of the newly added rewards.
Vulnerability Detail
Every time the distributeRewards() gets called, there will be a surge of pointsPerShare for the existing stakeholders.
This enables a well-known attack vector, in which the attacker will deposit a huge amount of underlying tokens and take a large portion of the pool, then trigger the surge, and exit right after.
Impact
While the existence of the MIN_LOCK_DURATION prevented the usage of flashloan, it's still possible for the attackers with sufficient funds or can acquire sufficient funds in other ways.
In which case, the attack is quite practical and effectively steal the major part of the newly added rewards
Code Snippet
Tool used
Manual Review
Recommendation
Consider using a rewardRate-based gradual release model, pioneered by Synthetix's StakingRewards contract.
See: https://github.com/Synthetixio/synthetix/blob/develop/contracts/StakingRewards.sol#L113-L132
Discussion
federava
Raising the MIN_LOCK_DURATION from 10 minutes to 1 day.
federava
PR from this issue
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the reward distribution is done in a single lump sum rather than gradually over time, allowing a large depositor to capture a disproportionate share of the newly added rewards.
Impact
An attacker with sufficient funds could steal a major part of the newly added rewards, although the minimum lock duration prevents using flash loans.
What the attacker needed
Sufficient funds to deposit; ability to deposit before reward distribution
The fix
The project should use a rewardRate-based gradual release model, similar to Synthetix's StakingRewards, and the team raised the minimum lock duration from 10 minutes to 1 day.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a staking pool, rewards are shared among everyone who has deposited tokens. If rewards are added all at once, someone can quickly deposit a large amount just before the reward is added, get a big share of it, and then withdraw right after. This is unfair to people who had been staking for a long time.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.