The function completeClaimRequest()
transfers tokens to a user but does not decrease the unclaimedRewards
before making the transfer.
This can result in a re-entrancy attack because if a malicious contract receives these tokens and immediately calls completeClaimRequest()
again before unclaimedRewards
is updated, it can drain the token supply.
https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordStaking.sol#L662-L687
The contract can be potentially vulnerable to a re-entrancy attack as the state variable unclaimedRewards
is updated after the external call to safeTransfer()
. An attacker can create a contract that calls completeClaimRequest()
in its fallback function resulting in multiple withdrawals.
A malicious contrast can drain the token supply
Manual review
To protect the function from a potential re-entrancy attack, it's advisable to make sure all internal state changes are made before calling any external contracts. The state variable should be updated before the call to safeTransfer()
.
In the completeClaimRequest()
function, reorder the statements as follows:
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.