You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 26, 2023. It is now read-only.
Curve LP staking allows adding false tokensIn to account by setting _claim_rewards to false
Summary
In CurveLPStakingController.sol and BalancerLPStakingController.sol, canDepositAndClaim() and canWithdrawAndClaim() assume that the user is claiming reward tokens, and add these tokens to the tokensIn array (to add to their account).
However, the only requirement to go down this code path is to use the full function signature (ie deposit(uint256,address,bool)), so false tokens will be added to a user account if they use the full signature with the _claim_rewards bool set to false.
Vulnerability Detail
Each Controller returns an array of tokensIn that will be added to the user's account, if they don't already hold a balance.
In CurveLPStakingController.sol and BalancerLPStakingController.sol, there are two overlapping pairs of function signatures:
deposit(uint256) and deposit(uint256,address,bool) are the same function, but the middle parameter (_addr) defaults to msg.sender and the final parameter (_claim_rewards) defaults to false
withdraw(uint256) and withdraw(uint256,bool) are the same function, but the final parameter (_claim_rewards) defaults to false
The assumption in the Controller logic is that, if a user uses the full signature, they are claiming their rewards. However, this isn't always the case. It is perfectly valid for a user to use the full function and pass false (the default argument) to the _claim_rewards parameter.
In this case, the function signature would lead to canDepositAndClaim() or canWithdrawAndClaim(), and all the rewards tokens would be added to the user's account.
Impact
Accounting on user accounts can be thrown off (intentionally or unintentionally), resulting in mismatches between their assets array and hasAsset mapping and the reality of their account.
In canCall(), decode the calldata to get the value of the _claim_rewards bool. If this value is false, call the non-claim version of the function (ie canDeposit() instead of canDepositAndClaim()).
The text was updated successfully, but these errors were encountered:
obront
medium
Curve LP staking allows adding false tokensIn to account by setting _claim_rewards to false
Summary
In CurveLPStakingController.sol and BalancerLPStakingController.sol,
canDepositAndClaim()
andcanWithdrawAndClaim()
assume that the user is claiming reward tokens, and add these tokens to thetokensIn
array (to add to their account).However, the only requirement to go down this code path is to use the full function signature (ie
deposit(uint256,address,bool)
), so false tokens will be added to a user account if they use the full signature with the_claim_rewards
bool set tofalse
.Vulnerability Detail
Each Controller returns an array of
tokensIn
that will be added to the user's account, if they don't already hold a balance.In CurveLPStakingController.sol and BalancerLPStakingController.sol, there are two overlapping pairs of function signatures:
deposit(uint256)
anddeposit(uint256,address,bool)
are the same function, but the middle parameter (_addr
) defaults tomsg.sender
and the final parameter (_claim_rewards
) defaults tofalse
withdraw(uint256)
andwithdraw(uint256,bool)
are the same function, but the final parameter (_claim_rewards
) defaults tofalse
The assumption in the Controller logic is that, if a user uses the full signature, they are claiming their rewards. However, this isn't always the case. It is perfectly valid for a user to use the full function and pass
false
(the default argument) to the_claim_rewards
parameter.In this case, the function signature would lead to
canDepositAndClaim()
orcanWithdrawAndClaim()
, and all the rewards tokens would be added to the user's account.Impact
Accounting on user accounts can be thrown off (intentionally or unintentionally), resulting in mismatches between their assets array and hasAsset mapping and the reality of their account.
Code Snippet
https://github.com/sherlock-audit/2022-11-sentiment/blob/main/controller-merged/src/balancer/BalancerLPStakingController.sol#L24-L25
https://github.com/sherlock-audit/2022-11-sentiment/blob/main/controller-merged/src/balancer/BalancerLPStakingController.sol#L52
https://github.com/sherlock-audit/2022-11-sentiment/blob/main/controller-merged/src/balancer/BalancerLPStakingController.sol#L72-L92
Tool used
Manual Review
Recommendation
In
canCall()
, decode the calldata to get the value of the_claim_rewards
bool. If this value is false, call the non-claim version of the function (iecanDeposit()
instead ofcanDepositAndClaim()
).The text was updated successfully, but these errors were encountered: