Skip to content

Commit 3788b23

Browse files
authored
Merge pull request #316 from hyperledger-labs/audit-202409-ibc-6
IBC-6: add module developer warning to doc of `sendPacket()` Signed-off-by: Jun Kimura <jun.kimura@datachain.jp>
2 parents 0471691 + af68fc1 commit 3788b23

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

contracts/core/04-channel/IBCChannelPacketSendRecv.sol

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,30 @@ contract IBCChannelPacketSendRecv is
3030
* @dev sendPacket is called by a module in order to send an IBC packet on a channel.
3131
* The packet sequence generated for the packet to be sent is returned. An error
3232
* is returned if one occurs. Also, `timeoutTimestamp` is given in nanoseconds since unix epoch.
33+
*
34+
* **Developer Warning: Mitigating DoS Attack Vectors in Packet Relay**
35+
*
36+
* Module contract developers using `sendPacket()` must ensure that there are no potential DoS attack vectors related to packet relay.
37+
* This is particularly critical for channels with an ORDERED ordering type, as packets that cannot be received on the destination chain (dst chain) will eventually timeout,
38+
* leading to the channel being closed. Such scenarios can cause serious problems for module users.
39+
* The following cases highlight potential scenarios where this vulnerability could occur. These have the common characteristic that the transaction for sending a packet on the source chain (src chain) is processable,
40+
* but the transaction for receiving the packet on the destination chain is not. If the module is applicable to these, in particular developers must carefully design the size of packet data and the gas consumption of packet send and receive operations for their module contracts.
41+
*
42+
* Potential Attack Vectors:
43+
*
44+
* 1. Large Packet Data Size
45+
*
46+
* Packet data must not result in a recvPacket transaction that exceeds the processing limits of the destination chain. This can happen in cases such as:
47+
*
48+
* - Different block gas limits between the src and dst chains: An attacker could send a large packet that can be processed on the src chain but exceeds the gas limit on the dst chain,
49+
* leading to an out-of-gas error and causing the packet to timeout. The larger the difference in block gas limits between the chains, the easier it becomes to exploit this vulnerability.
50+
* - Exceeding the maximum transaction size on the dst chain node: Blockchain nodes typically specify a maximum transaction size for inclusion in the mempool (e.g., 128KB in Geth).
51+
* This size restriction can often be exploited at a lower cost than exceeding the block gas limit, making it a critical consideration.
52+
*
53+
* 2. Imbalanced Gas Used Between Packet Sending and Receiving Logic
54+
*
55+
* If the gas used for sending a packet on the src chain is within its block gas limit, but the gas required for processing `recvPacket()` on the dst chain exceeds its gas limit, the `recvPacket()` transaction will fail due to an out-of-gas error.
56+
*
3357
*/
3458
function sendPacket(
3559
string calldata sourcePort,

0 commit comments

Comments
 (0)