Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insufficient Reward Distribution #28

Closed
c4-bot-7 opened this issue Feb 28, 2024 · 3 comments
Closed

Insufficient Reward Distribution #28

c4-bot-7 opened this issue Feb 28, 2024 · 3 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-369 🤖_06_group AI based duplicate group recommendation unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@c4-bot-7
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2024-02-uniswap-foundation/blob/main/src/UniStaker.sol#L570
https://github.com/code-423n4/2024-02-uniswap-foundation/blob/main/src/UniStaker.sol#L638

Vulnerability details

Impact:

Whenever a reward notifier initiates a reward cycle, it aims to distribute X amount of rewards during the duration of that cycle.

When there are no funds staked in the contract and it is notified for an award the amount of award that needs to be shared between of notifyRewardAmount() and the first stake() will remain locked in the account and will not be distributed.

There are no incentives to keep your tokens staked in the contract when there are no active rewards being distributed nor penalties for unstaking. Consequently, users may choose to stake their tokens only when rewards are available and unstake them when there are none.

Proof of Concept

Here is a coded POC which can be directly pasted in UniStaker.t.sol

function test_InsufficientRewardDistribution(
  ) public {
    address _depositor = makeAddr("_depositor");
    uint256 _stakeAmount = 1e18;

    uint256 _rewardAmount = 2_592_000e18; // 1 month in seconds * 1e18
     //first rewards are destributed without any stakes
    _mintTransferAndNotifyReward(_rewardAmount); 

    _jumpAheadByPercentOfRewardDuration(50);
    _boundMintAndStake(_depositor, _stakeAmount, _depositor); // depositor stakes
    _jumpAheadByPercentOfRewardDuration(51);

    _mintTransferAndNotifyReward(_rewardAmount); // more rewards are destributed
    _jumpAheadByPercentOfRewardDuration(101);

    vm.prank(_depositor);
    uniStaker.claimReward(); // depositor claims rewards

    console2.log("_depositor: balance ", uniStaker.REWARD_TOKEN().balanceOf(address(_depositor)));
    // _depositor: balance  3_888_000e18
    console2.log("unistaker: balance ", uniStaker.REWARD_TOKEN().balanceOf(address(uniStaker)));
    //locked unistaker: balance  1_296_000e18
  }

Tools Used:

  • Manual analysis

Recommendation:

Implement a mechanism to flag rewards that indicates that there are rewards that the contract was notified before any deposits. Use that flag to start the distribution upon the first stake.

Assessed type

Other

@c4-bot-7 c4-bot-7 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Feb 28, 2024
c4-bot-3 added a commit that referenced this issue Feb 28, 2024
@c4-bot-12 c4-bot-12 added the 🤖_06_group AI based duplicate group recommendation label Mar 5, 2024
@c4-judge c4-judge closed this as completed Mar 7, 2024
@c4-judge
Copy link
Contributor

c4-judge commented Mar 7, 2024

MarioPoneder marked the issue as duplicate of #9

@c4-judge
Copy link
Contributor

c4-judge commented Mar 7, 2024

MarioPoneder marked the issue as duplicate of #369

@c4-judge
Copy link
Contributor

MarioPoneder marked the issue as unsatisfactory:
Invalid

@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-369 🤖_06_group AI based duplicate group recommendation unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

3 participants