Skip to content
Business logic Audit finding Intermediate

freezing user rewards for a while

A smart contract function that calculates a user's accumulated rewards can revert because it subtracts the user's reward debt from the product of their LP position and the accumulated rewards per share, without first adding back any cached rewards. This causes the user's rewards to be locked until they earn enough new rewards to cover the debt.

cccz Follow with mahdikarimi, ABA and 3 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-02-olympus-judging/issues/187

Found by

cccz, mahdikarimi, ABA, xAlismx, GimelSec, Ruhum

Summary

When a user claims some cached rewards it's possible that rewards be freezed for a while .

Vulnerability Detail

the following line in internalRewardsForToken function can revert because already claimed rewards has been added to debt so if amount of debt be higher than accumulated rewards for user LP shares it will revert before counting cached rewards value so user should wait until earned rewards as much as last time he/she claimed rewards to be able claim it . uint256 totalAccumulatedRewards = (lpPositions[user_] * accumulatedRewardsPerShare) - userRewardDebts[user_][rewardToken.token];

Impact

user rewards will be locked for a while

Code Snippet

https://github.com/sherlock-audit/2023-02-olympus/blob/main/src/policies/lending/abstracts/SingleSidedLiquidityVault.sol#L354-L372

Tool used

Manual Review

Recommendation

add cached rewards to total rewards like the following line uint256 totalAccumulatedRewards = (lpPositions[user_] * accumulatedRewardsPerShare + cachedUserRewards[user_][rewardToken.token] ) - userRewardDebts[user_][rewardToken.token];

The original report as published on Sherlock, by cccz. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The calculation of total accumulated rewards does not include cached rewards before subtracting the user's reward debt, so the subtraction can underflow and revert.

Impact

User rewards are locked for a period until the user earns enough new rewards to cover the debt from previous claims.

What the attacker needed

User has claimed rewards before; user's reward debt exceeds newly earned rewards

The fix

The calculation should add the user's cached rewards to the product before subtracting the reward debt, so that the subtraction does not underflow.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

In a rewards system, when you claim your earned rewards, the contract records that you have been paid by increasing a 'debt' value. Later, when calculating how many rewards you have now, it subtracts that debt from your total earned rewards. If the debt is larger than the newly earned rewards, the subtraction goes negative and the transaction fails, so you cannot claim again until you have earned enough to cover the debt. This means your rewards are stuck for a while.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by cccz

View all

104 more disclosed reports, best first.

More from Olympus RBS 2.0

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.