A stream sender can withdraw funds on behalf of a stream recipient. This case is not handled in the staking contract.
The stream sender can withdraw the accumulated amount on behalf of the recipient to the recipient's account. When this happens, the onStreamWithdrawn https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordStaking.sol#L792 callback will be triggered, which is not handled in any way in the staking contract. As a result, the amount will be withdrawn to the staking contract's account (since it is the owner at the time of withdrawal). The stream owner will forfeit all withdrawn funds since they are no longer linked to the NFT. When the original owner regains possession of the NFT, they will be unable to recover the withdrawn tokens.
This is a dangerous situation because the sender, despite being authorized by the protocol's owners, is not an owner, and cannot be considered as fully trusted. The sender might even unintentionally automate withdrawals for recipients periodically, leading to the loss of vested stream funds for the recipient.
The test below demonstrates how this mechanism works. To run it, create it in the unit folder:
Tokens lost by the user.
Manual review.
Handle fund withdrawals in onStreamWithdrawn
https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordStaking.sol#L792. For example, transferred funds can be moved from the user's vested balance to the regular staking balance, in the same epoch the stream was originally staked, and treated as if they had been staked from the beginning using the standard staking method. This way, the user won't lose funds during the withdrawal and won't have to restake them again.
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.