Skip to content

Commit

Permalink
fix: CCIP messages should not be DoSable (#5448)
Browse files Browse the repository at this point in the history
### Description

Enable out of order message execution to prevent DoS. 

Set gas limit to benchmark from `forge test --isolate`.

Use 0 instead of msg.value in CCIP ISM.

### Backward compatibility

Yes

### Testing

Unit/Fork Tests
  • Loading branch information
yorhodes authored Feb 12, 2025
1 parent e78060d commit df0eb83
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .changeset/mean-cherries-reflect.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@hyperlane-xyz/core': minor
---

Implement CCIP hook and ISM
Implement CCIP hook and ISM with unordered execution
7 changes: 6 additions & 1 deletion solidity/contracts/hooks/CCIPHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ contract CCIPHook is AbstractMessageIdAuthHook {
receiver: abi.encode(ism),
data: abi.encode(message.id()),
tokenAmounts: new Client.EVMTokenAmount[](0),
extraArgs: "",
extraArgs: Client._argsToBytes(
Client.EVMExtraArgsV2({
gasLimit: 60_000,
allowOutOfOrderExecution: true
})
),
feeToken: address(0)
});
}
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/isms/hook/CCIPIsm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ contract CCIPIsm is AbstractMessageIdAuthorizedIsm, CCIPReceiver {
require(sender == authorizedHook, "Unauthorized hook");

bytes32 messageId = abi.decode(any2EvmMessage.data, (bytes32));
preVerifyMessage(messageId, msg.value);
preVerifyMessage(messageId, 0);
}

function _isAuthorized() internal view override returns (bool) {
Expand Down
3 changes: 3 additions & 0 deletions solidity/test/isms/CCIPIsm.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ contract CCIPIsmTest is Test {
Client.Any2EVMMessage memory message = _encodeCCIPReceiveMessage();

vm.prank(OP_ROUTER_ADDRESS);
uint256 beforeCall = gasleft();
ccipISMOptimism.ccipReceive(message);
uint256 afterCall = gasleft();
console.log("Gas used: ", beforeCall - afterCall);

assertTrue(ccipISMOptimism.verifiedMessages(messageId).isBitSet(255));
}
Expand Down

0 comments on commit df0eb83

Please sign in to comment.