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

REWARD_TOKEN can be locked in the UniStaker when no deposit exists #177

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 edited-by-warden 🤖_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/cde876f5eed60eb2df4104cf031ddc21b1f538b9/src/UniStaker.sol#L570

Vulnerability details

Impact

The reward will be locked when no deposit exists in the current UniStaker contract.

Proof of Concept

When no deposit exists in the current contract, which means the stake amount is 0.
However, the reward notifier can arbitrarily to invoke notifyRewardAmount to add the new rewards.

    if (block.timestamp >= rewardEndTime) {
      scaledRewardRate = (_amount * SCALE_FACTOR) / REWARD_DURATION; //@audit what if end a long time ago? check challenge.cc
    } else {
      uint256 _remainingReward = scaledRewardRate * (rewardEndTime - block.timestamp);
      scaledRewardRate = (_remainingReward + _amount * SCALE_FACTOR) / REWARD_DURATION;
    }

Assume the scaledRewardRate is 10 * SCALE_FACTOR, after 900 seconds, the first stake coming, the checkpoint will be updated and the reward start.

However, no rewards are distributed among the first 900 seconds, the 10 * 900 rewards will be locked.

Reference: https://code4rena.com/reports/2022-09-y2k-finance#m-15-rewards-are-not-rolled-over

Tools Used

Manual

Recommended Mitigation Steps

Adding additional flags to record the 0 deposit timestamp and accumulated rewards. And consider rolling it back to the staking reward.

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-4 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 c4-judge closed this as completed Mar 6, 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
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 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

4 participants