The stake function does not follow the check-effects-interaction pattern. It adds the users' staked amount before transferring the tokens from the user, making it possible for a malicious user to call the stake function with a malicious contract that has a fallback function to reenter the function. This can increase their stake amount without transferring the tokens.
Steps to reproduce the hack
A malicious user will call the stake function with a malicious contract several times to increase their deposit amount in the deposit receipt, thereby increasing their amount of FJORD tokens.
Since the points will not be given to the user, only the amount will be added to their deposits.
The user will call the unstake function and withdraw all the FJORD tokens from the contract.
Tokens staked by other users and protocol tokens will be stolen.
Manual Review
Use ReentrancyGuard from OpenZeppelin, which allows you to add a modifier, e.g., nonReentrant, to functions that may otherwise be vulnerable. Follow the check-effects-interactions pattern as shown below.
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.