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

Merged
merged 5 commits into from
Jan 24, 2025

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.

@Sean329 Sean329 requested review from Sean329 and removed request for dpaiton and slundqui January 23, 2025 20:40
@coveralls
Copy link
Collaborator

coveralls commented Jan 23, 2025

Pull Request Test Coverage Report for Build 12938071562

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.006%) to 89.235%

Totals Coverage Status
Change from base Build 12644755306: 0.006%
Covered Lines: 2918
Relevant Lines: 3270

💛 - Coveralls

@jalextowle jalextowle added this pull request to the merge queue Jan 23, 2025
@jalextowle jalextowle removed this pull request from the merge queue due to a manual request Jan 23, 2025
* Allow traders to specify the counterparty and fee recipient of their trades

* Added a non-reentrancy modifier to `cancelOrders` (#1229)
@jalextowle jalextowle enabled auto-merge January 23, 2025 22:56
@jalextowle jalextowle added this pull request to the merge queue Jan 24, 2025
Merged via the queue into main with commit 3497650 Jan 24, 2025
35 checks passed
@jalextowle jalextowle deleted the jalextowle/fix/on-morpho-callback-caller branch January 24, 2025 01:18
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.

4 participants