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

fix(protocol): verify target address is a contract address in DelegateOwner #17328

Merged
merged 1 commit into from
May 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
dantaik marked this conversation as resolved.
Show resolved Hide resolved
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