Skip to content
Business logic Audit finding Intermediate

After the vault expires, users may still receive rewards through the StakingRewards contract

After a vault epoch ends, its tokens become worthless, but the associated StakingRewards contract may still allow staking those tokens to earn rewards. An attacker could stake expired tokens and receive rewards intended for future valid epochs.

cccz Follow

Originally disclosed on Code4rena

Submitted by cccz

When the triggerEndEpoch function of the Controller contract is called, the assets in the insrVault will be sent to the riskVault, which also means that the tokens in the insrVault will be worthless.

insrVault.setClaimTVL(epochEnd, 0);
...
        else {
            entitledAmount = amount.divWadDown(idFinalTVL[id]).mulDivDown(
                idClaimTVL[id],
                1 ether
            );
        }

However, if the periodFinish > _epochEnd in the StakingRewards contract corresponding to the insrVault, the user can continue to stake his insrToken and receive rewards.

Proof of Concept

https://github.com/code-423n4/2022-09-y2k-finance/blob/ac3e86f07bc2f1f51148d2265cc897e8b494adf7/src/Controller.sol#L223

https://github.com/code-423n4/2022-09-y2k-finance/blob/ac3e86f07bc2f1f51148d2265cc897e8b494adf7/src/Vault.sol#L418-L423

https://github.com/code-423n4/2022-09-y2k-finance/blob/ac3e86f07bc2f1f51148d2265cc897e8b494adf7/src/rewards/StakingRewards.sol#L183-L210

Recommended Mitigation Steps

Add the following code at the end of the notifyRewardAmount function of the StakingRewards contract to limit the periodFinish

         lastUpdateTime = block.timestamp;
         periodFinish = block.timestamp.add(rewardsDuration);
+       require(periodFinish <= id);

MiguelBits (Y2K Finance) disputed

HickupHH3 (judge) commented:

Agree with issue; I view this as protocol leaked value (rewards) because it enables expired vault tokens that have no / little worth to “steal” rewards from future valid epochs. 1 time mint, lifetime rewards doesn’t seem right.


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

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

Impact

An attacker could stake expired, worthless tokens to earn rewards meant for future valid epochs, leaking value from the protocol.

What the attacker needed

Expired vault tokens; staking rewards contract active

The fix

The StakingRewards contract should be modified to ensure that the reward period finish time does not exceed the vault epoch end time.

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.

A vault is a place where users lock tokens for a period. When the period ends, the tokens are supposed to be worthless. But a separate rewards contract still lets people stake those worthless tokens and earn rewards. This means someone could get rewards without having done anything useful.

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 Y2k Finance contest

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.