Aura/Convex rewards are stuck after DOS
The Convex rewards adapter measured claimed rewards by comparing token balances before and after calling the external Convex contract, but anyone can trigger a claim for the Tokemak contract directly. An attacker could pre-claim the rewards so the adapter's balance difference is zero, leaving the tokens stuck in the LiquidationRow contract instead of being queued to the MainRewarder.
0x007 Follow with 0x73696d616f, ADM and 11 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-06-tokemak-judging/issues/738
Found by
0x007, 0x73696d616f, ADM, bin2chen, caelumimperium, ck, ctf_sec, minhtrng, nobody2018, pengun, pks_, saidam017, tives, xiaoming90
Since _claimRewards accounts for rewards with balanceBefore/After, and anyone can claim Convex rewards, then attacker can DOS the rewards and make them stuck in the LiquidationRow contract.
Vulnerability Detail
Anyone can claim Convex rewards for any account.
https://etherscan.io/address/0x0A760466E1B4621579a82a39CB56Dda2F4E70f03#code
function getReward(address _account, bool _claimExtras) public updateReward(_account) returns(bool){
uint256 reward = earned(_account);
if (reward > 0) {
rewards[_account] = 0;
rewardToken.safeTransfer(_account, reward);
IDeposit(operator).rewardClaimed(pid, _account, reward);
emit RewardPaid(_account, reward);
}
//also get rewards from linked rewards
if(_claimExtras){
for(uint i=0; i < extraRewards.length; i++){
IRewards(extraRewards[i]).getReward(_account);
}
}
return true;
}
In ConvexRewardsAdapter, the rewards are accounted for by using balanceBefore/after.
function _claimRewards(
address gauge,
address defaultToken,
address sendTo
) internal returns (uint256[] memory amounts, address[] memory tokens) {
uint256[] memory balancesBefore = new uint256[](totalLength);
uint256[] memory amountsClaimed = new uint256[](totalLength);
...
for (uint256 i = 0; i < totalLength; ++i) {
uint256 balance = 0;
// Same check for "stash tokens"
if (IERC20(rewardTokens[i]).totalSupply() > 0) {
balance = IERC20(rewardTokens[i]).balanceOf(account);
}
amountsClaimed[i] = balance - balancesBefore[i];
return (amountsClaimed, rewardTokens);
Adversary can call the external convex contract’s getReward(tokemakContract). After this, the reward tokens are transferred to Tokemak without an accounting hook.
Now, when Tokemak calls claimRewards, then no new rewards are transferred, because the attacker already transferred them. amountsClaimed will be 0.
Impact
Rewards are stuck in the LiquidationRow contract and not queued to the MainRewarder.
Code Snippet
// get balances after and calculate amounts claimed
for (uint256 i = 0; i < totalLength; ++i) {
uint256 balance = 0;
// Same check for "stash tokens"
if (IERC20(rewardTokens[i]).totalSupply() > 0) {
balance = IERC20(rewardTokens[i]).balanceOf(account);
}
amountsClaimed[i] = balance - balancesBefore[i];
if (sendTo != address(this) && amountsClaimed[i] > 0) {
IERC20(rewardTokens[i]).safeTransfer(sendTo, amountsClaimed[i]);
}
}
Tool used
Manual Review
Recommendation
Don’t use balanceBefore/After. You could consider using balanceOf(address(this)) after claiming to see the full amount of tokens in the contract. This assumes that only the specific rewards balance is in the contract.
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 adapter inferred the claimed amount from a before/after balance difference on an externally triggerable claim, so a third party could consume the claim first and make the difference zero.
Impact
Rewards could be stuck in the LiquidationRow contract and never queued to the MainRewarder, denying users their rewards.
What the attacker needed
Attacker can call Convex getReward; rewards pending for the Tokemak contract
The fix
The adapter should not rely on a before/after balance difference; it should measure the contract's token balance after claiming instead.
How it was found
- The attacker calls the external Convex contract's getReward function for the Tokemak contract address.
- The reward tokens are transferred to Tokemak without any accounting hook being triggered.
- Tokemak later calls claimRewards, but no new tokens arrive because they were already sent.
- The calculated claimed amount is zero, so the rewards are not queued to the MainRewarder.
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 smart contract pays out rewards to whoever asks for them on behalf of an account. The project's code worked out how much it received by checking its balance before and after asking for the payout. Because an outsider could ask for the payout first, the project's own request then received nothing, and the money already sitting in its account was never passed on to users.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.