Skip to content
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

Ensure that Morpho is the caller of onMorphoFlashLoan #1227

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jalextowle
Copy link
Contributor

Description

Fixes a critical vulnerability in the matching engine. Previously anyone could call onMorphoFlashLoan which could be used to drain approvals by circumventing the validation logic.

@Sean329
Copy link

Sean329 commented Dec 16, 2024

LGTM,
@jalextowle but a nit for thoughts: in the current code, if the immediate returned proceeds is smaller than lpAmount, then the trxn will revert with a quite general error code like SafeERC20FailedOperation(); if we require(proceeds >= lpAmount) within the body of onMorphoFlashLoan then we have the chance to give it a better clarified internal error code.

However, it comes with a con which is that, we will lose the potential workaround to "help" some matchOrder to succeed by donating some base tokens into the match engine contract even when the liquidity amount returned from hyperdrive is not good enough.

@jalextowle
Copy link
Contributor Author

LGTM, @jalextowle but a nit for thoughts: in the current code, if the immediate returned proceeds is smaller than lpAmount, then the trxn will revert with a quite general error code like SafeERC20FailedOperation(); if we require(proceeds >= lpAmount) within the body of onMorphoFlashLoan then we have the chance to give it a better clarified internal error code.

However, it comes with a con which is that, we will lose the potential workaround to "help" some matchOrder to succeed by donating some base tokens into the match engine contract even when the liquidity amount returned from hyperdrive is not good enough.

I'm glad you brought this up. It's good to think about this. As discussed offline, we'll keep as-is based on your last comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants