-
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
Depeg event can happen at incorrect price #69
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Comments
After discussion , the docs clearly state only below the strike Price
|
@MiguelBits Exactly when it is below the strike price but in this case depeg is happening when price is equal and not below |
Oh I see what you mean, need to correct it! |
Ah, a matter of when the equality sign matters a lot. Critically, in this case. Agree with warden that it should be |
This was referenced Oct 18, 2022
This was referenced Nov 5, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Controller.sol#L96
Vulnerability details
Impact
Depeg event can still happen when the price of a pegged asset is equal to the strike price of a Vault which is incorrect.
This docs clearly mentions:
"When the price of a pegged asset is below the strike price of a Vault, a Keeper(could be anyone) will trigger the depeg event and both Vaults(hedge and risk) will swap their total assets with the other party." - https://code4rena.com/contests/2022-09-y2k-finance-contest
Proof of Concept
Assume strike price of vault is 1 and current price of pegged asset is also 1
User calls triggerDepeg function which calls isDisaster modifier to check the depeg eligibility
Now lets see isDisaster modifier
Since in our case price of vault=price of pegged asset so if condition does not execute and finally isDisaster completes without any revert meaning go ahead of depeg
But this is incorrect since price is still not below strike price and is just equal
Recommended Mitigation Steps
Change the isDisaster modifier to revert when price of a pegged asset is equal to the strike price of a Vault
The text was updated successfully, but these errors were encountered: