Skip to content

Commit

Permalink
fix(protocol): verify target address is a contract address in Delegat…
Browse files Browse the repository at this point in the history
…eOwner (#17328)
  • Loading branch information
dantaik authored May 25, 2024
1 parent 0e85144 commit 0c3c0e1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/protocol/contracts/L2/DelegateOwner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity 0.8.24;

import "../common/EssentialContract.sol";
import "../common/LibStrings.sol";
import "../libs/LibAddress.sol";
import "../libs/LibBytes.sol";
import "../bridge/IBridge.sol";

Expand Down Expand Up @@ -41,6 +42,7 @@ contract DelegateOwner is EssentialContract, IMessageInvocable {

error DO_DRYRUN_SUCCEEDED();
error DO_INVALID_PARAM();
error DO_INVALID_TARGET();
error DO_INVALID_TX_ID();
error DO_PERMISSION_DENIED();
error DO_TARGET_CALL_REVERTED();
Expand Down Expand Up @@ -106,6 +108,9 @@ contract DelegateOwner is EssentialContract, IMessageInvocable {

if (_verifyTxId && call.txId != nextTxId++) revert DO_INVALID_TX_ID();

// By design, the target must be a contract address.
if (!Address.isContract(call.target)) revert DO_INVALID_TARGET();

(bool success, bytes memory result) = call.isDelegateCall //
? call.target.delegatecall(call.txdata)
: call.target.call{ value: msg.value }(call.txdata);
Expand Down

0 comments on commit 0c3c0e1

Please sign in to comment.