ConvexStakingWrapper.sol after shutdown,rewards can be stolen
After the contract is shut down, reward checkpoints stop updating, so a new user who receives tokens has a zero reward integral and can claim rewards they never earned. By transferring tokens to fresh addresses and claiming repeatedly, an attacker could drain all remaining rewards.
Submitted by bin2chen
After shutdown, checkpoints are stopped, leading to possible theft of rewards.
Proof of Concept
ConvexStakingWrapper No more checkpoints after shutdown, i.e. no updates reward.reward_integral_for[user]
function _beforeTokenTransfer(
address _from,
address _to,
uint256
) internal override {
@> _checkpoint([_from, _to]);
}
function _checkpoint(address[2] memory _accounts) internal nonReentrant {
//if shutdown, no longer checkpoint in case there are problems
@> if (isShutdown()) return;
uint256 supply = _getTotalSupply();
uint256[2] memory depositedBalance;
depositedBalance[0] = _getDepositedBalance(_accounts[0]);
depositedBalance[1] = _getDepositedBalance(_accounts[1]);
IRewardStaking(convexPool).getReward(address(this), true);
_claimExtras();
uint256 rewardCount = rewards.length;
for (uint256 i = 0; i < rewardCount; i++) {
_calcRewardIntegral(i, _accounts, depositedBalance, supply, false);
}
}
This would result in, after shutdown, being able to steal rewards by transferring tokens to new users.
Example:
Suppose the current
reward.reward_integral = 1000
When a shutdown occurs:
- Alice transfers 100 to the new user, Bob.
Since Bob is the new user and _beforeTokenTransfer()->_checkpoint() is not actually executed.
Result:
balanceOf[bob] = 100
reward.reward_integral_for[bob] = 0
- Bob executes
claimRewards()to steal the reward.
reward amount = balanceOf[bob] * (reward.reward_integral - reward.reward_integral_for[bob]) = 100 * (1000-0)
- Bob transfers the balance to other new users, looping steps 1-2 and stealing all rewards.
Recommended Mitigation Steps
Still execute \_checkpoint
function _checkpoint(address[2] memory _accounts) internal nonReentrant {
//if shutdown, no longer checkpoint in case there are problems
- if (isShutdown()) return;
uint256 supply = _getTotalSupply();
uint256[2] memory depositedBalance;
depositedBalance[0] = _getDepositedBalance(_accounts[0]);
depositedBalance[1] = _getDepositedBalance(_accounts[1]);
IRewardStaking(convexPool).getReward(address(this), true);
_claimExtras();
uint256 rewardCount = rewards.length;
for (uint256 i = 0; i < rewardCount; i++) {
_calcRewardIntegral(i, _accounts, depositedBalance, supply, false);
}
}
Assessed type
Context
pmckelvy1 (Reserve) acknowledged
Skip reward claim in
_checkpointif shutdown. PR: https://github.com/reserve-protocol/protocol/pull/930
Status: Mitigation confirmed. Full details in reports from ronnyx2017, bin2chen and RaymondFam.
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 checkpoint function returns early when the contract is shut down, so reward accounting is never updated for token transfers.
Impact
After shutdown, an attacker could steal all remaining rewards by cycling tokens through new addresses.
What the attacker needed
Contract is shut down; attacker can transfer tokens to new addresses
The fix
The checkpoint function should still run after shutdown, or reward claims should be skipped during shutdown, as the mitigation did.
How it was found
- A shutdown occurs, so checkpoints are no longer executed.
- Alice transfers tokens to a new user, Bob.
- Bob's reward integral remains zero because the checkpoint was skipped.
- Bob calls claimRewards and receives rewards based on his full balance.
- Bob transfers the balance to other new users and repeats to steal all rewards.
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 contract tracks how many rewards each user is owed by recording a running total when tokens move. After a shutdown, that recording stops, so a new user starts with a zero record and can claim rewards as if they had held tokens all along. An attacker can repeat this with new addresses to take rewards that belong to others.
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.