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: add fix for checking for correct messageId in OPL2ToL1Ism and ArbL2ToL1Ism via external call #4437

Merged
merged 29 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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 .changeset/itchy-singers-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/core': patch
---

Patched OPL2ToL1Ism to check for correct messageId for external call in verify
1 change: 1 addition & 0 deletions solidity/contracts/isms/hook/ArbL2ToL1Ism.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ contract ArbL2ToL1Ism is
) external override returns (bool) {
if (!isVerified(message)) {
_verifyWithOutboxCall(metadata, message);
require(isVerified(message), "ArbL2ToL1Ism: message not verified");
}
releaseValueToRecipient(message);
return true;
Expand Down
4 changes: 2 additions & 2 deletions solidity/contracts/isms/hook/OPL2ToL1Ism.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ contract OPL2ToL1Ism is
bytes calldata metadata,
bytes calldata message
) external override returns (bool) {
bool verified = isVerified(message);
aroralanuk marked this conversation as resolved.
Show resolved Hide resolved
if (!verified) {
if (!isVerified(message)) {
_verifyWithPortalCall(metadata, message);
require(isVerified(message), "OPL2ToL1Ism: message not verified");
}
releaseValueToRecipient(message);
return true;
Expand Down
2 changes: 2 additions & 0 deletions solidity/test/isms/ERC5164ISM.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ contract ERC5164IsmTest is ExternalBridgeTest {

function test_verify_valueAlreadyClaimed(uint256) public override {}

function test_verify_false_arbitraryCall() public override {}

/* ============ helper functions ============ */

function _externalBridgeDestinationCall(
Expand Down
20 changes: 18 additions & 2 deletions solidity/test/isms/ExternalBridgeTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ abstract contract ExternalBridgeTest is Test {
1 ether,
messageId
);
ism.verify(externalCalldata, encodedMessage);
assertTrue(ism.verify(externalCalldata, encodedMessage));
assertEq(address(testRecipient).balance, 1 ether);
}

function test_verify_revertsWhen_invalidIsm() public virtual {
bytes memory externalCalldata = _encodeExternalDestinationBridgeCall(
address(hook),
address(this),
address(hook),
0,
messageId
);
Expand Down Expand Up @@ -217,6 +217,19 @@ abstract contract ExternalBridgeTest is Test {
assertEq(address(testRecipient).balance, _msgValue);
}

function test_verify_false_arbitraryCall() public virtual {
bytes memory incorrectCalldata = _encodeExternalDestinationBridgeCall(
address(hook),
address(this),
0,
messageId
);

vm.expectRevert();
ism.verify(incorrectCalldata, encodedMessage);
assertFalse(ism.isVerified(encodedMessage));
}

/* ============ helper functions ============ */

function _encodeTestMessage() internal view returns (bytes memory) {
Expand Down Expand Up @@ -265,4 +278,7 @@ abstract contract ExternalBridgeTest is Test {
function _setExternalOriginSender(
address _sender
) internal virtual returns (bytes memory) {}

// meant to mock an arbitrary successful call made by the external bridge
function verifyMessageId(bytes32 /*messageId*/) public payable {}
}
10 changes: 6 additions & 4 deletions solidity/test/isms/OPStackIsm.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ contract OPStackIsmTest is ExternalBridgeTest {
}

function _encodeExternalDestinationBridgeCall(
address _from,
address _to,
uint256 _msgValue,
bytes32 _messageId
address /*_from*/,
address /*_to*/,
uint256 /*_msgValue*/,
bytes32 /*_messageId*/
) internal pure override returns (bytes memory) {
return new bytes(0);
}
Expand All @@ -148,6 +148,8 @@ contract OPStackIsmTest is ExternalBridgeTest {

function test_verify_revertsWhen_invalidIsm() public override {}

function test_verify_false_arbitraryCall() public override {}

/* ============ ISM.verifyMessageId ============ */

function test_verify_revertsWhen_notAuthorizedHook() public override {
Expand Down
Loading