The FjordStaking
contract allows users to stake Fjord tokens and streams from Sablier protocol to accrue Fjord points. The logic in handling Sablier streams is faulty, which allows a premitted Sablier staker to game the system to get more points.
The core logic behind Sablier's streaming service is to distribute a given amount of tokens equally across set duration, for example, a stream may send total 1000 tokens in the course of 10 days, this means the stream would send 100 tokens per day, to eventually accumulate 1000 tokens at the end of stream. There are also varities of options on how users can send their funds, some sends a fixed amount, some will lock the funds for an amount of time, and then dirtsibute the rest funds. The reason of introducing the concept of streams is due to how it's handled in stakeVested
:
We see that staked amount is determined from depositedAmount - (withdrawnAmount + refundedAmount);
, for the sake of simplicity, let's assume withdrawn and refunded amounts are both none, which then leads to amount = depositedAmount
. This will be the staked amount recorded in the contract, and user's reward is also calculated based on it. And from one of the contract in Sablier's repository, we see:
And such variable is set in:
So, for a stream which will total send 1000 tokens, user will deposit this entire amount clean, then the stream can be created, and this makes the deposited amount to be 1000 tokens, as expected. However, remember that a duration can be set for streams, and for a linear stream, funds will be sent equally through out the duration.
Note that each epoch set for staking round is 7 days, and it's possible to set the Sablier duration to a much longer time span, for example, a year. In this case, suppose Alice deposits 365000 tokens as stream, sets the duration to one year, which makes the daily flow to be 1000 tokens. Immediately after, Alice stakes this newly created stream, with amount being 365000. After 35 days, which means 5 whole epoch rounds has passed, Alice has accrued enough points, and wants to withdraw/unstake her stream. At this point, Alice has transferred 35000 tokens to FjordStaking
, which is less than 1/10 of the total amont she is supposed to put in, but she will get rewards as if she actually staked 365000 tokens.
As explained above, a malicious user can abuse the streaming property and game the system, to pay more tokens, but get more points.
Manual review
Calculate and distribute rewards for streams based on how much the contract actually received, instead of using deposited amount directly.
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.