The FjordPoints and FjordStaking contracts are designed to reward users with points tokens based on their staked amounts over epoch intervals. However, due to a timing discrepancy introduced during the deployment sequence, it is possible for an attacker to exploit this arrangement to claim points without having their tokens locked for a full epoch. Specifically, the FjordPoints
contract initializes its epoch from the block timestamp at deployment, and the FjordStaking
contract does similarly but is deployed subsequently in a different block. This time difference allows attackers to manipulate the system by strategically staking and unstaking tokens around epoch changes, thus violating the intended incentives.
The issue arises from the interaction between the FjordPoints
and FjordStaking
contracts. Primarily, the constructors and epoch management logic in the following functions:
FjordPoints Constructor:
FjordStaking Constructor:
Initialization Time Difference:
The lastDistribution
timestamp for FjordPoints
is initialized during its own deployment.
The startTime
for FjordStaking
is initialized subsequently when the staking contract is deployed.
Due to separate deployment blocks, there is an inherent slight difference in these timestamps.
Epoch Change Discrepancy:
Points are distributed based on the lastDistribution
timestamp in FjordPoints
.
Staking logic in FjordStaking
checks epochs based on its own startTime
.
An attacker can stake tokens just before an epoch change in FjordPoints
and then unstake immediately after the points are distributed but before FjordStaking
registers the epoch change.
Potential Exploit:
By carefully timing the staking and unstaking operations, an attacker can repeatedly claim points without having their tokens locked for a required epoch duration, thereby gaining unearned rewards.
An attacker could strategically exploit the timing discrepancy between the deployment of the FjordPoints
and FjordStaking
contracts by spamming the Ethereum network to raise gas prices. By doing so, they can intentionally delay the deployment of the FjordStaking
contract after the FjordPoints
contract has already been deployed. This artificial delay extends the window during which the FjordPoints
contract's epoch can change before the staked tokens are recognized by the FjordStaking
contract.
This vulnerability allows an attacker to claim unearned rewards by exploiting the timing discrepancy between the FjordPoints
contract and the FjordStaking
contract epoch start times.
Logs
Foundry
Initialize lastDistribution
during setStakingContract
:
Instead of setting lastDistribution
in the FjordPoints
constructor, set it during the setStakingContract
call.
Synchronize Epoch Start Times:
Retrieve the start time directly from the FjordStaking
contract within the setStakingContract
function. This ensures that both contracts are aligned in terms of epoch timing.
Impact: High - Users are getting an unreasonable amount of points through exploiting a vulnerability Likelihood: Low - Most of the times, when using the script, all deployment tx will get processed in the same block. But, there is a small chance for them to be processed in different blocks.
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.