A malicious user can deposit 1 wei
worth of tokens just before an award is added to the FjordStaking
contract, causing the rewardPerToken
value to be greatly inflated, leading to the user obtaining more rewards than others. The same issue is propagated in the FjordPoints
contract, as the pointsPerToken
also depends on the totalStaked
, as every time FjordTokens
are staked in FjordStaking
, points are accumulated in the FjordPoints
contract.
When a user calls FjordStaking::stake(...)
with just 1 wei
, it updates the totalSupply
of the staking contract to 1 wei
, which after the next award accumulation and epoch rollover will cause the rewardPerToken for that epoch to be greatly inflated due to multiplying by PRECISION_18
and expecting the totalSupply
to also be with e18
(leading to values in the range of e36
).
The same scenario is observed in the FjordPoints
contract as well because staking in FjordStaking
adds staked amount in the FjordPoints
contract as well:
Inside FjordPoints
we have a special function called distributePoints(...), which calculates how much FjordPoints
a user should get based on the staked FjordTokens
:
The above miscalculations will not only lead to the initial user obtaining more FjordTokens
in rewards but will also accumulate more FjordPoints
afterward, leading to an enormous advantage over the other users.
Alice monitors the transaction pool and sees that the Fjord admin is about to add a reward.
Alice front-runs the transactions and stakes 1 wei
.
The admin adds the reward and time starts passing.
Bob decides to stake and Alice starts staking as well, where both users stake normal amounts - 2e18
for example.
Both users wait for the cycle to end so that they can unstake and claim their rewards.
Even though Alice has staked 1 wei
more than Bob, she gets A LOT more than Bob.
Afterwards, both Bob and Alice claim their FjordPoints
, and again Alice has an unfair advantage over Bob.
I have used my testing suite to avoid invalid mocks as the original one.
A malicious user can inflate the reward per token values, thus obtaining more rewards than he/she deserves, as well as allowing for more points to be later claimed.
Manual review
Set a minimum amount of tokens that can be deposited, so that the rewards per token could never be inflated in such a way.
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.