You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
onlyEOA in MorphoLeverageStrategyExtension relies on tx.origin on certain function like rebalance and ripcord to various attack vectors like sandwiching, re-entrancy, etc.
from EIP 7702:
Once code exists in the EOA, it's possible for self-sponsored EIP-7702 transactions to have msg.sender == tx.origin anytime the code in the EOA dispatches a call. Without EIP-7702, this situation can only ever arise in the topmost execution layer of a transaction. Therefore, this EIP breaks that invariant and so it affects smart contracts containing require(msg.sender == tx.origin) checks. This check is used for at least three purposes:
Ensuring that msg.sender is an EOA (given that tx.origin always has to be an EOA). This invariant does not depend on the execution layer depth and, therefore, is not affected.
Protecting against atomic sandwich attacks like flash loans, which rely on the ability to modify state before and after the execution of the target contract as part of the same atomic transaction. This protection would be broken by this EIP. However, relying on tx.origin in this way is considered bad practice, and can already be circumvented by miners conditionally including transactions in a block.
Preventing reentrancy.
Root Cause
As mentioned in summary, tx.origin check is insufficient
Internal pre-conditions
N/A
External pre-conditions
EIP7702 being approved (which is very likely as per ACD in next hardfork)
Attack Path
Sandwich the rebalance and ripcord transaction by selling loanToken/collateralToken, followed by rebalance then buying back loanToken/collateralToken cheaper
It also opens up various possibility of re-entrancy leading to grieving by flash loaning all funds from morpho and calling rebalance inside callback which needs to be explored further for impact.
Impact
Loss for all the LPs due to getting bad exchanges rates or in worst case leading to some undefined behavior due to re-entrancy.
PoC
same as "Attack Path" section
Mitigation
solution for checking EOA or not would be non-trivial post EIP 7702
The text was updated successfully, but these errors were encountered:
sherlock-admin2
changed the title
Silly Slate Goblin - onlyEOA modifier will not work as expected after EIP 7702
hack3r-0m - onlyEOA modifier will not work as expected after EIP 7702
Oct 28, 2024
hack3r-0m
Medium
onlyEOA
modifier will not work as expected after EIP 7702Summary
onlyEOA
inMorphoLeverageStrategyExtension
relies ontx.origin
on certain function likerebalance
andripcord
to various attack vectors like sandwiching, re-entrancy, etc.from EIP 7702:
Root Cause
As mentioned in summary, tx.origin check is insufficient
Internal pre-conditions
N/A
External pre-conditions
Attack Path
Sandwich the rebalance and ripcord transaction by selling loanToken/collateralToken, followed by rebalance then buying back loanToken/collateralToken cheaper
It also opens up various possibility of re-entrancy leading to grieving by flash loaning all funds from morpho and calling rebalance inside callback which needs to be explored further for impact.
Impact
Loss for all the LPs due to getting bad exchanges rates or in worst case leading to some undefined behavior due to re-entrancy.
PoC
same as "Attack Path" section
Mitigation
solution for checking EOA or not would be non-trivial post EIP 7702
The text was updated successfully, but these errors were encountered: