-
Notifications
You must be signed in to change notification settings - Fork 12
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 on stake()
in SafEth.sol
#150
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
M-12
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
Comments
0xSorryNotSorry marked the issue as duplicate of #949 |
0xSorryNotSorry marked the issue as duplicate of #365 |
Picodes marked the issue as satisfactory |
Picodes changed the severity to 3 (High Risk) |
Picodes changed the severity to 2 (Med Risk) |
Picodes marked the issue as selected for report |
This was referenced Apr 24, 2023
Closed
This was referenced Apr 24, 2023
Open
This was referenced May 8, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
M-12
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
Lines of code
https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/SafEth.sol#L63-L101
Vulnerability details
Impact
mintAmount
is determined both bytotalStakeValueEth
andpreDepositPrice
. While the former is associated with external interactions beyond users' control, the latter should be linked to a slippage control to incentivize more staker participations.Proof of Concept
As can be seen from the code block below,
ethPerDerivative()
serves to get the price of each derivative in terms of ETH. Although it is presumed the prices entailed would be closely/stably pegged 1:1, no one could guarantee the degree of volatility just as what has recently happened to the USDC depeg.File: SafEth.sol#L71-L81
When
underlyingValue
is less thantotalSupply
,preDepositPrice
will be smaller and inversely makemintAmount
bigger, and vice versa.Any slight change in price movement in the same direction can be consistently cumulative and reflective in stake calculations. This can make two stakers calling
stake()
with the same ETH amount minutes apart getting minted different amount of stake ERC20 tokens.Tools Used
Manual
Recommended Mitigation Steps
Consider having a user inputtable
minMintAmountOut
added in the function parameters ofstake()
and the function logic refactored as follows:Ideally, this slippage calculation should be featured in the UI, with optionally selectable stake amount impact, e.g. 0.1%.
The text was updated successfully, but these errors were encountered: