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
The ripcord function in the MorphoLeverageStrategyExtension contract relies on the onlyEOA modifier to restrict access to externally owned accounts (EOAs). However, this check is insufficient as a reentrancy guard. Without proper reentrancy protection, the function is vulnerable to reentrancy attacks, which could lead to unintended state changes or financial loss.
Root Cause
The contract uses the onlyEOA modifier, which checks msg.sender == tx.origin, to ensure that only EOAs can call the ripcord function. This approach is not a substitute for a reentrancy guard because it does not prevent contracts from re-entering functions during execution. Additionally, future Ethereum proposals like EIP-3074 could allow contracts to impersonate EOAs, rendering the onlyEOA check ineffective.
modifier onlyEOA() {
require(msg.sender==tx.origin, "Must be EOA address");
_;
}
function ripcord(stringmemory_exchangeName) external onlyEOA {
// Function logic...uint256 etherTransferred =_transferEtherRewardToCaller(incentive.etherReward);
//...
}
Internal Pre-conditions
The contract holds an Ether balance sufficient to pay the incentive reward.
The ripcord function is callable and intended to be used during high leverage situations.
External Pre-conditions
An attacker can deploy a malicious contract designed to exploit reentrancy.
The attacker is motivated to drain the contract's Ether balance or manipulate its state.
Attack Path
Preparation: The attacker deploys a malicious contract capable of re-entering the ripcord function.
Invocation: The attacker calls the ripcord function via their malicious contract.
Reentrancy: During the Ether transfer in _transferEtherRewardToCaller, the attacker re-enters the ripcord function.
Exploitation: The attacker repeats this process to drain Ether rewards or manipulate the contract state.
Impact
Financial Loss: The attacker can drain the Ether balance allocated for rewards.
State Manipulation: Unintended changes to leverage positions or other sensitive state variables.
Contract Disruption: The contract may behave unpredictably or enter an invalid state.
Estimated Loss
The attacker could potentially drain all Ether allocated for incentives. The exact amount depends on the contract's Ether balance but could be significant.
Mitigation
Implement Reentrancy Guard: Use a reentrancy guard, such as OpenZeppelin's ReentrancyGuard, to prevent reentrancy attacks.
Avoid Reliance on onlyEOA: Do not rely solely on onlyEOA for security-critical functions.
Conclusion
The reliance on the onlyEOA modifier in the ripcord function is insufficient for reentrancy protection. Implementing proper reentrancy guards ensures the function is secure against reentrancy attacks, both now and in the future, even if Ethereum's capabilities evolve.
The text was updated successfully, but these errors were encountered:
sherlock-admin2
changed the title
Odd Hotpink Antelope - Insufficient Reentrancy Protection in ripcord Function Due to Reliance on onlyEOA Modifier
AdamSzymanski - Insufficient Reentrancy Protection in ripcord Function Due to Reliance on onlyEOA Modifier
Oct 28, 2024
AdamSzymanski
Medium
Insufficient Reentrancy Protection in
ripcord
Function Due to Reliance ononlyEOA
ModifierSummary
Very similar issue as in this Sherlock report
The
ripcord
function in theMorphoLeverageStrategyExtension
contract relies on theonlyEOA
modifier to restrict access to externally owned accounts (EOAs). However, this check is insufficient as a reentrancy guard. Without proper reentrancy protection, the function is vulnerable to reentrancy attacks, which could lead to unintended state changes or financial loss.Root Cause
The contract uses the
onlyEOA
modifier, which checksmsg.sender == tx.origin
, to ensure that only EOAs can call theripcord
function. This approach is not a substitute for a reentrancy guard because it does not prevent contracts from re-entering functions during execution. Additionally, future Ethereum proposals like EIP-3074 could allow contracts to impersonate EOAs, rendering theonlyEOA
check ineffective.Code Location
MorphoLeverageStrategyExtension.sol
ripcord
Internal Pre-conditions
ripcord
function is callable and intended to be used during high leverage situations.External Pre-conditions
Attack Path
ripcord
function.ripcord
function via their malicious contract._transferEtherRewardToCaller
, the attacker re-enters theripcord
function.Impact
Estimated Loss
The attacker could potentially drain all Ether allocated for incentives. The exact amount depends on the contract's Ether balance but could be significant.
Mitigation
Implement Reentrancy Guard: Use a reentrancy guard, such as OpenZeppelin's
ReentrancyGuard
, to prevent reentrancy attacks.Avoid Reliance on
onlyEOA
: Do not rely solely ononlyEOA
for security-critical functions.Conclusion
The reliance on the
onlyEOA
modifier in theripcord
function is insufficient for reentrancy protection. Implementing proper reentrancy guards ensures the function is secure against reentrancy attacks, both now and in the future, even if Ethereum's capabilities evolve.The text was updated successfully, but these errors were encountered: