Skip to content
Smart contracts Audit finding Intermediate

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.

obront Follow

Originally disclosed on Sherlock

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).

Solidity
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

https://github.com/sherlock-audit/2022-11-sentiment/blob/main/controller-merged/src/balancer/BalancerLPStakingController.sol#L30-L31

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.

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

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.

More by obront

View all

46 more disclosed reports, best first.

More from Sentiment Update #3

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.