This repository has been archived by the owner on Sep 15, 2024. It is now read-only.
ComposableSecurity - Nesting remote transfer messages to steal tokens #136
Labels
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
High
A valid High severity issue
Reward
A payout will be made for this issue
Sponsor Disputed
The sponsor disputed this issue's validity
Won't Fix
The sponsor confirmed this issue will not be fixed
ComposableSecurity
high
Nesting remote transfer messages to steal tokens
Summary
The user can use a nested
MSG_REMOTE_TRANSFER
message in a validMSG_REMOTE_TRANSFER
to execute back the remote transfer as the owner of tokens (stealing their tokens). Additionally, the allowance check can be easily bypassed so the attacker can make an unauthorized cross-transfer of any supported token belonging to any user (victim).Vulnerability Detail
Tapioca allows to execute a cross-chain call to make a remote transfer.
https://github.com/sherlock-audit/2024-02-tapioca/blob/main/Tapioca-bar/gitmodule/tapioca-periph/contracts/tapiocaOmnichainEngine/TapiocaOmnichainReceiver.sol#L214-L233
It works as following:
MSG_REMOTE_TRANSFER
message to destination chain with specified amount of tokens and owner of the tokens (e.g. the user themselves).composeMsg
field ofRemoteTransferMsg
struct.https://github.com/sherlock-audit/2024-02-tapioca/blob/main/Tapioca-bar/gitmodule/tapioca-periph/contracts/interfaces/periph/ITapiocaOmnichainEngine.sol#L76-L80
The main issue here is that the
_internalRemoteTransferSendPacket
function is called withremoteTransferMsg_.owner
as the first parameter, which is the_srcChainSender
parameter. In other words, the executor or the callback call is the owner (not the user who initiated the process). Additionally, the user can arbitrarily specify the contents of thecomposeMsg
in theMSG_REMOTE_TRANSFER
message (step 1). It can have a nestedMSG_REMOTE_TRANSFER
message that would be called by the owner.What is more, the attacker is able to bypass the allowance check by simply making the outer
MSG_REMOTE_TRANSFER
for zero amount. The allowance check for 0 amount always passes and allows to execute the nestedMSG_REMOTE_TRANSFER
.Let's explore the attack scenario:
MSG_REMOTE_TRANSFER
message to destination chain with 0 amount of tokens and the victim as the owner of the tokens.MSG_REMOTE_TRANSFER
message by the victim with the victim as the owner and the balance of the victim as the amount.from == sender
.amount
of tokens from the victim to Tapioca.amount
of tokens.composeMsg
).See the Proof of Concept:
Impact
HIGH - Theft of any supported token held by any user on any chain.
Code Snippet
https://github.com/sherlock-audit/2024-02-tapioca/blob/main/Tapioca-bar/gitmodule/tapioca-periph/contracts/tapiocaOmnichainEngine/TapiocaOmnichainReceiver.sol#L214-L233
Tool used
Manual Review
Recommendation
Validate the compose message to not include nested compose messages or build the callback message from scratch as simple LZ transfer message.
Duplicate of #111
The text was updated successfully, but these errors were encountered: