Component: Mailbox
Description
Mailbox is the chain-local endpoint of Hyperlane messaging. It is responsible for dispatching outbound messages and running any configured hooks, and processing inbound messages after the configured Interchain Security Module (ISM) verifies them.
Mailbox provides a public interface for following actions:
Dispatch : Users invoke a
dispatchfunction in order to send interchain messages. When called, it constructs aHyperlaneMessagefrom the arguments passed, including the nonce, the domain identifier of the source chain, the domain identifier of the destination chain, the sender's address, the recipient's address, and the message to be sent. It then invokes the configured post-dispatch hooks, emit events to notify that a message is sent, and returns any leftover payment buckets to the caller.
Process : Relayers invoke a
processfunction in order to deliver interchain messages to this component. When called, it passes the message and metadata to the recipient's ISM to verify the message. If the message is verified, the recipient'shandlefunction will be invoked with the delivered message as an argument, finalizing the delivery.
Quote : Users can call the
quote_dispatchfunction to check the fee incurred when invokingdispatch.
On instantiation, the component reserves its address, mints a 1-of-1 owner badge, and sets authentication on methods so that only the owner can change the configured addresses of the ISM and hooks.
Invariants
The destination domain of the message must be equal to the Mailbox's
local_domain. This is enforced by a check in theprocessfunction, preventing any mis-routed messages to be processed.
Each message can be processed only once. This is enforced by a check in the
processfunction, preventing replay of messages.
The sender of the message must be equal to the address of the account or component that called the
dispatchfunction. This is enforced by a check in thedispatchfunction, preventing the sender of the message from being spoofed.
Test coverage
Cases covered
Instantiation of the Mailbox component
process: Domain mismatch is rejectedprocess: Unsupported message version is rejectedprocess: Revert when recipient doesn't implement expected app/ISM interfacedispatch: Message is successfully dispatcheddispatch: Forged sender address is rejected
Cases not covered
process: Replay protectiondispatch: Hook interactionset_default_ism/set_default_hook/set_required_hook: Access control
After the primary audit period, Hyperlane introduced negative tests covering these cases in PR 29↗ to improve the project's test coverage.
Attack surface
Externally controllable inputs to
dispatchfunction :destination_domain,recipient_addressandmessage_bodyaffect message ID, hook execution, and emitted events. Malicious payloads can target the recipient app and should be gated by recipient logic on the destination chain.Callers can route payment through setting arbitrary
hookandhook_metadatawhen calling this function; a malicious hook can steal the caller's own payment. The owner-setrequired_hookis always invoked; if the owner configures a malicious hook, it can overly extract the user payments. However, this is an expected centralization risk akin to setting fee collectors.Hooks can consume the
paymentprovided by the caller. If the payment is insufficient to cover the gas, the transaction will be reverted.If
claimed_account_senderis forged, theverify_message_senderfunction prevents spoofing by asserting rules against the current caller's proofs or global-caller context.
Externally controllable inputs to
processfunction :metadataandraw_messageare fully controlled by an attacker or relayer. The check for the destination chain and replay protection are performed as mentioned above, and the final verification is carried out by the recipient's ISM.visible_componentsis forwarded to the recipient. Recipients may require specific component addresses, e.g., for deposits. A malicious relayer can pass arbitrary addresses, and the recipients are responsible for rejecting those with their own logic.
Owner-controlled configuration risk : The owner can set or modify
default_ism,default_hookandrequired_hook. If compromised or malicious, they can weaken verification or overly extract user payments.