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

Part of the reward tokens can be permanently frozen in extreme cases. #350

Closed
c4-bot-2 opened this issue Mar 4, 2024 · 3 comments
Closed
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-2
Copy link
Contributor

c4-bot-2 commented Mar 4, 2024

Lines of code

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

Vulnerability details

Impact

In extreme cases, a portion of the reward tokens may be permanently frozen, particularly when there are no Uni tokens staked.

Assessing the vulnerability as Medium or Low (info) is challenging due to the lack of explicit discussion about scenarios where TotalStaked == 0. The reality is that when TotalStaked == 0, reward tokens are effectively "burned" (i.e., distributed to no one) and thus become frozen.

The question of whether this issue should be considered a vulnerability is subject to debate. I classify it as Medium because I believe a straightforward/simple solution exists to prevent such permanent freezing.

Proof of Concept

It's important to note that the absence of staked Uni tokens (TotalStaked == 0) prevents any increase in rewardPerTokenAccumulatedCheckpoint.

Two scenarios could lead to this issue:

First, if there are no staked tokens and a notifier calls notifyRewardAmount, the reward tokens will be distributed to no recipient.

Second, if the last stakeholder withdraws their entire deposit, rewardPerTokenAccumulatedCheckpoint ceases to increase, despite increases in block.timestamp and lastCheckpointTime. This situation results in the reward tokens being frozen.

Recommended Mitigation Steps

The straightforward and easiest strategy is to ensure that 1) notifyRewardAmount cannot be invoked when TotalStaked == 0, and 2) withdrawals cannot deplete all staked tokens.

Note that, these measures (two simple checks) incentivize MEV bots to deposit at least 1 Wei of Uni Token.

Assessed type

Other

@c4-bot-2 c4-bot-2 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 4, 2024
c4-bot-3 added a commit that referenced this issue Mar 4, 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 c4-judge added duplicate-369 unsatisfactory does not satisfy C4 submission criteria; not eligible for awards and removed duplicate-9 labels Mar 7, 2024
@c4-judge
Copy link
Contributor

MarioPoneder marked the issue as unsatisfactory:
Invalid

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