Curve LP Controller withdraw and claim function uses wrong signature
The controller contracts used an incorrect function selector for the withdraw-and-claim operation, so calls to withdraw from Balancer pools would fail. Users could not claim rewards when withdrawing from Balancer pools, though Curve pools were unaffected because their actual signature matched the selector.
Source: https://github.com/sherlock-audit/2022-11-sentiment-judging/issues/23
Found by
obront
Summary
The function signature used for WITHDRAWCLAIM in both CurveLPStakingController.sol and BalancerLPStakingController.sol are incorrect, leading to the function not succeeding.
Vulnerability Detail
In both the CurveLPStakingController.sol and BalancerLPStakingController.sol contracts, the function selector 0x00ebf5dd is used for WITHDRAWCLAIM. This selector corresponds to a function signature of withdraw(uint256,address,bool).
bytes4 constant WITHDRAWCLAIM = 0x00ebf5dd;
However, the withdraw() function in the Curve contract does not have an address argument. Instead, the function signature reads withdraw(uint256,bool), which corresponds to a function selector of 0x38d07436.
Impact
Users who have deposited assets into Curve pools will not be able to claim their rewards when they withdraw their tokens.
Code Snippet
Tool used
Manual Review
Recommendation
Change the function selector in both contracts to 0x38d07436.
Discussion
ruvaag
The Curve docs don't reflect this but both 2CRV and crv3Crypto expose withdraw(uint256,address,bool) so this issue is invalid when looking at CRV LP tokens
That being said, Balancer exposes withdraw(uint256,bool) instead of withdraw(uint256,address,bool) so we will implement a fix to that effect.
ruvaag
Disagree with severity because users could use the claim_rewards function to claim pending rewards. But agree with the issue.
r0ohafza
Fix: https://github.com/sentimentxyz/controller/pull/48
zobront
Fix confirmed.
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 developers assumed the withdraw function signature was the same across Curve and Balancer pools, but Balancer uses a different signature, so the hardcoded selector did not match.
Impact
Users withdrawing from Balancer pools could not claim their rewards in the same transaction, though they could still claim pending rewards separately using the claim_rewards function.
What the attacker needed
User has deposited into a Balancer pool; user withdraws and expects to claim rewards
The fix
The function selector in the Balancer controller was changed to match the correct withdraw signature, and the fix was confirmed.
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 function selector is a short code that tells a smart contract which function to run. The code here used the wrong code for the withdraw function on Balancer pools, so the withdraw call would not work and rewards could not be claimed in the same step. Curve pools were not affected because their withdraw function actually matched the code used.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.