Malicious Users Can Duplicate Protocol Earned Yield By Transferring wCVX Tokens To Another Account
The ConvexYieldWrapper contract omitted a checkpoint on token transfers, so a user could transfer wCVX tokens to another account and manually checkpoint the recipient, causing both accounts to show the same deposited balance. This allowed the attacker to claim more than their fair share of rewards, draining yield from other users.
Submitted by leastwood, also found by kenzo
ConvexYieldWrapper.sol is a wrapper contract for staking convex tokens on the user’s behalf, allowing them to earn rewards on their deposit. Users will interact with the Ladle.sol contract’s batch() function which:
- Approves Ladle to move the tokens.
- Transfers the tokens to
ConvexYieldWrapper.sol. - Wraps/stakes these tokens.
- Updates accounting and produces debt tokens within
Ladle.sol.
During wrap() and unwrap() actions, _checkpoint() is used to update the rewards for the from_ and to_ accounts. However, the reference contract implements a _beforeTokenTransfer() function which has been removed from Yield Protocol’s custom implementation.
As a result, it is possible to transfer wCVX tokens to another account after an initial checkpoint has been made. By manually calling user_checkpoint() on the new account, this user is able to update its deposited balance of the new account while the sender’s balance is not updated. This can be repeated to effectively replicate a user’s deposited balance over any number of accounts. To claim yield generated by the protocol, the user must only make sure that the account calling getReward() holds the tokens for the duration of the call.
Proof of Concept
The exploit can be outlined through the following steps:
- Alice receives 100
wCVXtokens from the protocol after wrapping their convex tokens. - At that point in time,
_getDepositedBalance()returns 100 as its result. A checkpoint has also been made on this balance, giving Alice claim to her fair share of the rewards. - Alice transfers her tokens to her friend Bob who then manually calls
user_checkpoint()to update his balance. - Now from the perspective of the protocol, both Alice and Bob have 100
wCVXtokens as calculated by the_getDepositedBalance()function. - If either Alice or Bob wants to claim rewards, all they need to do is make sure the 100
wCVXtokens are in their account upon callinggetReward(). Afterwards, the tokens can be transferred out.
Tools Used
Manual code review. Discussion/confirmation with the Yield Protocol team.
Recommended Mitigation Steps
Consider implementing the _beforeTokenTransfer() function as shown in the reference contract. However, it is important to ensure the wrapper contract and collateral vaults are excluded from the checkpointing so they are not considered in the rewards calculations.
alcueca (Yield) confirmed and commented:
Confirmed. The fact that rewards can be drained also means that users lose on their expected rewards, so I think that Sev 3 is right.
Alex the Entreprenerd (judge) commented:
In systems that track growing rewards, anytime a user balances changes, it’s important to recalculate their balances as to properly distribute pending rewards and to influence the future-rate at which rewards will be distributed (process generally called
accruing)In the case of the ConvexYieldWrapper, the warden has shown that because the
wCVXtoken doesn’t perform a_checkpointon each transfer, a malicious attacker could repeatedly transfer their tokens in order to reuse the same balance in multiple accounts, effectively sybil attacking the protocol.The fix seems to be straightforward, however the impact of the finding breaks the accounting of the protocol, as such I believe High Severity to be appropraite
Alex the Entreprenerd (judge) commented:
The sponsor has mitigated in a subsequent PR by overriding the
_transferfunction
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
A malicious user could repeatedly duplicate their balance across accounts to claim more rewards than deserved, which also means other users lose out on their expected rewards.
What the attacker needed
A user holds wCVX tokens; ability to call user_checkpoint() and getReward()
How it was found
- Alice receives 100 wCVX tokens after wrapping her convex tokens, and a checkpoint records her balance.
- Alice transfers her tokens to Bob, who manually calls user_checkpoint() to update his balance.
- Both Alice and Bob now appear to have 100 wCVX tokens according to the protocol.
- Either Alice or Bob ensures the tokens are in their account when calling getReward(), then transfers them out afterwards.
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 that tracks how many tokens each person has deposited to share out rewards. When tokens move between accounts, the contract is supposed to update both the sender's and receiver's reward records. It forgot to do that, so the same tokens could be counted for two people at once, letting them take more rewards than they should.
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.