Skip to content
Access control Audit finding Intermediate

Dual transaction nature of composed message transfer allows anyone to steal user funds

0xTheC0der Follow with d3e4 and oakcobalt

Originally disclosed on Code4rena

Submitted by 0xTheC0der, also found by d3e4 and oakcobalt

Sending OFTs with a composed message via LayerZero V2 involves 2 transactions on the destination chain (Canto) according to the documentation (see also README):

  1. Receiving: The LayerZero endpoint receives the message and processes the OFT transfer to the ASDRouter contract.
  2. Executing: Since the message is composed, it’s permissionlessly processed by an executor who invokes the lzCompose(…) method of the ASDRouter contract.

The above steps are processed in separate transactions (not atomic) and step 2 requires the OFTs to be already transferred to the ASDRouter contract.

Furthermore, due to the permissionless nature of the execution step, the lzCompose(…) method does not enforce any constraints on the msg.sender; therefore, allows anyone to invoke it.

Attack path:

An adversary can monitor the ASDRouter contract for whitelisted incoming USDC-like OFTs and immediately use those on their own (redeem asD) by crafting & invoking a call to lzCompose(…) before an executor does. As a consequence, user funds are directly stolen.

Similarly, if lzCompose(…) fails for any reason, an adversary can re-try before the user to use the OFTs.

Proof of Concept

The dual transaction nature of the current composed message process is confirmed by the LayerZero documentation:

If the message is composed, the contract retrieves and re-encodes the additional composed message information, then delivers the message to the endpoint, which will execute the additional logic as a separate transaction.

Moreover, crafting a successful call to lzCompose(…) once OFTs are deposited is demonstrated by the existing test case “lzCompose: successful deposit and send on canto”.

Recommended Mitigation Steps

Immediate, but not a satisfying fix: Restrict the lzCompose(…) method to trusted/whitelisted executors.

Alternative: Design change by directly implementing _lzReceive(…) (building an OApp) such that a composed message is not needed anymore.

Assessed type

Invalid Validation

3docSec (judge) commented:

Looks legitimate: lzCompose is permissionless and can be front-run because LayerZero calls it in a separate transaction after funds are delivered.

dsudit01 (Canto) confirmed and commented:

PR here.


The original report as published on Code4rena, by 0xTheC0der. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A high-severity access control bug in Canto. Code4rena made it public on 3 May 2024. Found in the 2024-03-canto audit contest (finding H-02), also found by 2 other wardens.

About Access control

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by 0xTheC0der

View all

11 more disclosed reports, best first.

More from Canto

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.