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

Rewards accrued before first deposit will remain stuck forever #158

Closed
c4-bot-8 opened this issue Mar 3, 2024 · 3 comments
Closed

Rewards accrued before first deposit will remain stuck forever #158

c4-bot-8 opened this issue Mar 3, 2024 · 3 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-369 edited-by-warden 🤖_06_group AI based duplicate group recommendation unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@c4-bot-8
Copy link
Contributor

c4-bot-8 commented Mar 3, 2024

Lines of code

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

Vulnerability details

Impact

A vulnerability in the in the UniStaker contract can cause rewards to become permanently locked if they are notified before any deposits have been made into the pool. This means that rewards allocated during this period are irretrievable, due to the contract's inability to distribute these early rewards.

As a result, these funds cannot be claimed by any participants or returned, leading to a loss of funds intended as rewards.

Proof of Concept

Take the following example scenario:

  1. Initially, the contract has no staked tokens (totalStaked = 0)
  2. Rewards notifier calls UniStaker#notifyRewardAmount(30 WETH) which results in scaledRewardRate = 1 WETH:
scaledRewardRate = 30 WETH / 30 days = 1 WETH/day
  1. 20 days pass without any staking activity.
  2. Alice stakes some WETH on day 20.
  3. 10 days pass and rewardEndTime is reached.
  4. Alice claims her share, calculated to be 10 WETH for her 10-day staking period:
Alice's Reward = 1 WETH/day * 10 days = 10 WETH

However, the 20 WETH of rewards from the first 20 days remain unclaimed and are stuck in the contract forever.

Tools Used

Manual Review

Recommended Mitigation Steps

To prevent rewards from becoming locked in the contract before any staking activity, the contract should revert calls to UniStaker#notifyRewardAmount() when there are no active stakers.

This approach ensures that rewards cannot be notified prematurely, avoiding the issue of locked rewards.

Assessed type

Error

@c4-bot-8 c4-bot-8 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 Mar 3, 2024
c4-bot-1 added a commit that referenced this issue Mar 3, 2024
@c4-bot-7 c4-bot-7 removed the 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value label Mar 3, 2024
@code4rena-admin code4rena-admin added 3 (High Risk) Assets can be stolen/lost/compromised directly edited-by-warden labels Mar 3, 2024
@c4-bot-12 c4-bot-12 added the 🤖_06_group AI based duplicate group recommendation label Mar 5, 2024
@c4-judge
Copy link
Contributor

c4-judge commented Mar 6, 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
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-369 edited-by-warden 🤖_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

5 participants