M-1: An attacker can sweep arbitrary adapter token balances from Wormhole adapter
Description:
WormholeSwapAdapter.receiveWormholeMessages() and WormholeDepositAdapter.receiveWormholeMessages() decode token and amount from the untrusted payload before checking whether sourceChain and sourceAddress are whitelisted emitters. If the emitter is not whitelisted, both functions enter a fallback branch that calls BridgeAdapterBase._forwardAvailable(token, recipient, amount).
_forwardAvailable() does not verify that token is the asset actually delivered by Wormhole. It only checks the adapter's current balance for the attacker-chosen token and transfers min(balance, amount). As a result, any caller reaching the Wormhole relayer callback path with an unapproved emitter can name an arbitrary ERC20 already resident in the adapter and force the fallback branch to transfer it out.
Attack path:
The adapter enforces two layers of authentication:
_onlyWhitelistedEndpoint()— verifiesmsg.senderis the Wormhole relayer contract on the destination chain.whitelistedWormholeEmitters[sourceChain][sourceAddress]— verifies the originating contract on the source chain is trusted.
The Wormhole relayer is a permissionless delivery service. An attacker can trigger the fallback path as follows:
- Send a Wormhole message from any supported source chain targeting the adapter address on the destination chain, with a crafted payload. This only costs the Wormhole relay fee.
- The Wormhole guardians sign the VAA. The
sourceAddressandsourceChainare cryptographically authenticated and genuinely reflect the attacker's address. - The Wormhole relayer on the destination chain calls
adapter.receiveWormholeMessages(payload, [], sourceAddress, sourceChain, hash). Sincemsg.senderis the Wormhole Relayer,_onlyWhitelistedEndpoint()passes. - The attacker's
sourceAddressis not inwhitelistedWormholeEmitters, so the adapter enters the fallback branch. - The fallback decodes
token,amount, andrecipientfrom the attacker-controlled payload and calls_forwardAvailable(token, recipient, amount), transferringmin(adapterBalance, amount)of the chosen token to the attacker.
Impact:
Medium. Residual ERC20 balances left in either Wormhole adapter can be stolen by unapproved Wormhole senders. Any dust, accidental transfers, or temporarily stranded user funds in the adapter become sweepable to an attacker-controlled address.
Recommendation:
Consider removing the whitelisted emitter check as part of the Executor migration and use the fallback at strategy level.