Skip to content
Business logic Audit finding Intermediate

Reward tokens can never be added again once they are removed without breaking rewards completely

The contract tracks accumulated rewards globally in a per-token struct and individually in a per-user mapping. When a reward token is removed, only the global tracker is cleared, so re-adding the token causes an underflow when users try to claim rewards.

cccz Follow with cducrest-brainbot, 0x52 and 1 other

Originally disclosed on Sherlock

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

Found by

cccz, cducrest-brainbot, 0x52, hansfriese

Summary

Once reward tokens are removed they can never be added back to the contract. The happens because accumulated rewards are tracked differently globally vs individually. Global accumulated rewards are tracked inside the rewardToken array whereas it is tracked by token address for users. When a reward token is removed the global tracker is cleared but the individual trackers are not. If a removed token is added again, the global tracker will reset to zero but the individual tracker won't. As a result of this claiming will fail due to an underflow.

Vulnerability Detail

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

The amount of accumulated rewards for a specific token is tracked in it's respective rewardToken struct.

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

For individual users the rewards are stored in a mapping.

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

When a reward token is removed the global tracker for the accumulated rewards is also removed. The problem is that the individual mapping still stores the previously accumulated rewards. If the token is ever added again, the global accumulated reward tracker will now be reset but the individual trackers will not. This will cause an underflow anytime a user tries to claim reward tokens.

Impact

Reward tokens cannot be added again once they are removed

Code Snippet

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

Tool used

ChatGPT

Recommendation

Consider tracking accumulatedRewardsPerShare in a mapping rather than in the individual struct or change how removal of reward tokens works

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

Likely the global accumulated rewards per share are stored in a struct that is deleted on token removal, while per-user accumulated rewards are stored in a mapping that is not cleared, causing a mismatch and underflow on re-adding the token.

Impact

Reward tokens cannot be added again once they are removed, because any claim attempt will fail due to an underflow.

What the attacker needed

Reward token previously removed; same token re-added; user attempts to claim

The fix

The accumulated rewards per share should be tracked in a mapping rather than in the individual struct, or the removal of reward tokens should be changed so that individual trackers are also cleared.

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.

This is a smart contract bug where the total rewards for a token and each user's share are stored in two different places. Removing a token resets only the total, not the users' shares, so if the token is added back, the numbers no longer match and the contract crashes when someone tries to claim.

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.