An attacker can break the pre-conditions of the FjordStaking#addReward
function by front-running, which leads to the rewards be wrongly distributed.
There is a NatSpec for the FjordStaking#addReward
function
The protocol intends to call this function when:
This action is the last action of the current epoch.
This action triggers the update of next epoch, in other words, this action triggers the function _checkEpochRollover
.
But an attacker can break these pre-conditions by front-running the function addReward
with any functions that have a modifier checkEpochRollover
(E.g: stake
). This will causes the staking rewards be wrongly distributed, to be more precise, the staking rewards will be distributed one epoch after and the rewards will be for one more epoch.
Consider the following scenario:
At the end of the third epoch, the protocol calls to addReward
to distribute the staking rewards for the second and first epoch.
An attacker front-runs the protocol's transaction with any function that have a modifier checkEpochRollover
. The epoch gets rollover, and now the current epoch is the fourth epoch.
The staking rewards will be distributed at the start of the fifth epoch, and it will be for the third, the second, and the first epoch.
test/POC/POC.t.sol
Logs
When there is no attack, the rewards will be distributed at the start of the fourth epoch, and the rewards will be for the second and first epoch. When the attacker performs the attack, the rewards will be distributed at the start of the fifth epoch, and the rewards will be for the third, second, and first epoch.
An attacker can break the pre-conditions of the FjordStaking#addReward
function, which leads to the rewards be wrongly distributed.
Manual Review.
Add a buffered time (E.g: 10 minutes) at the start of every epoch. During the buffered time, only the protocol can interact with the FjordStaking
contract. The protocol adding rewards during the buffered time will guarantee the pre-conditions of the FjordStaking#addReward
function are met.
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.