-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No slippage protection when depositing funds into strategies #343
Comments
0xSorryNotSorry marked the issue as primary issue |
This is good information for Strategy designers to have, but does not appear to have appreciable impact at the moment, so seems more appropriate to have informational severity. We may consider adding an optional parameter in the future. |
Sidu28 marked the issue as disagree with severity |
I believe, per this line: /**
* @notice calculation of newShares *mirrors* `underlyingToShares(amount)`, but is different since the balance of `underlyingToken`
* has already been increased due to the `strategyManager` transferring tokens to this strategy prior to calling this function
*/
if (totalShares == 0) {
newShares = amount;
} else {
uint256 priorTokenBalance = _tokenBalance() - amount;
if (priorTokenBalance == 0) {
newShares = amount;
} else {
newShares = (amount * totalShares) / priorTokenBalance;
}
} That the Strategies are vulnerable to rebase griefs, so the slippage check is necessary |
With the information I have available:
Which is a valid Medium Severity, callers should use a router to ensure they receive the intended amount of shares |
GalloDaSballo marked the issue as selected for report |
All duplicates are related to rebasing shares as a way to attack depositors Imo it is best to add a router or a minOut parameter as to avoid people getting funds lost, griefed or stolen Because this has been mitigated somewhat to only cause a loss of yield, (1e9 magnitude less due to min deposit), I believe Medium Severity to be the most appropriate |
The issue described in #343 is not a lack of slippage protection. This is rather the suggested mitigation. It is claimed that the lack of slippage protection “will put the user who deposits at risk as anyone can front run his transcation by depositing a large amount and thus when the user transactions proceeds he will receive a very small amount of shares not the amount he was expecting.”. Depositing doesn’t change the share price, so this is obviously false, but I’ll (generously) assume that the warden meant to frontrun with a direct transfer of funds as the first depositor. |
GalloDaSballo changed the severity to QA (Quality Assurance) |
GalloDaSballo marked the issue as not selected for report |
Lines of code
https://github.com/code-423n4/2023-04-eigenlayer/blob/main/src/contracts/core/StrategyManager.sol#L655-L672
Vulnerability details
Impact
The internal function
_depositIntoStrategy
is responsible of depositing funds into strategies (except the BeaconETH strategy) when a user calls one of the functionsdepositIntoStrategy
ordepositIntoStrategyWithSignature
, because_depositIntoStrategy
does not implement a slippage protection the user deposit transaction can be front runned and the user will not receive the shares amount that he has expected but he will receive a smaller amount.Proof of Concept
When a user wants to make a deposit to a given strategy(except the BeaconETH strategy) he must call one of the functions :
depositIntoStrategy
ordepositIntoStrategyWithSignature
, which internally call the internal function_depositIntoStrategy
to transfer funds and get shares from the strategy contract.The issue occurs in the
_depositIntoStrategy
function :File: StrategyManager.sol Line 655-672
As it can be seen from the code above the function transfer the funds to the strategy contract and then calls the
strategy.deposit
function which return the correspanding shares amount (it's worth noting that thestrategy.deposit
function also does not implement a slippage protection, it just checks that the returned share amount is not equal to 0), after getting the shares amount the function uses it directly without checking for eventual slippage, this will put the user who deposits at risk as anyone can front run his transcation by depositing a large amount and thus when the user transactions proceeds he will receive a very small amount of shares not the amount he was expecting.Because the
strategy.deposit
function can be different from one strategy to another as it can be overridden, it is important to implement a slippage protection inside the_depositIntoStrategy
function to ensure that users are protected when depositing to any strategy.Tools Used
Manual review
Recommended Mitigation Steps
I recommend to add a slippage protection in the
_depositIntoStrategy
function, this can be done by adding aminSharesOut
argument to the function (provided by the user) and checking if the returned shares amount from the strategy is above it or not. The_depositIntoStrategy
function can be modified as follows :Assessed type
Token-Transfer
The text was updated successfully, but these errors were encountered: