Smart Security Practices From The Best
What do Lido, Red Stone, YieldNest, and Braintrust have in common? They’ve developed effective methods for improving security without drastically increasing costs. Top-tier protocol […]
The function executes modules depending on the _msgType parameter and some of them do not accept the _srcChainSender parameter.
The _toeComposeReceiver function is called by the LayerZero endpoint (indirectly) when there is a compose message to be executed. It gets three parameters.
The first parameter (_msgType) represents the type of message that should be executed on the destination chain. The second (_srcChainSender) is the sender of the message on the source chain and last one (_toeComposeMsg) contains the parameters for the executed operation.
In case of MSG_TAP_EXERCISE the _srcChainSender parameter is forwarded to the UsdoOptionReceiver module.
In case of other types (MSG_MARKET_REMOVE_ASSET, MSG_YB_SEND_SGL_LEND_OR_REPAY and MSG_DEPOSIT_LEND_AND_SEND_FOR_LOCK) the _srcChainSender parameter is not forwarder and the attacker fully control the contents of _toeComposeMsg.
Let’s take the MSG_MARKET_REMOVE_ASSET message as an example.
removeAssetReceiver function from UsdoMarketReceiverModule is executed with _toeComposeMsg parameter._toeComposeMsg bytes (called _data in this function) are decoded and some values are extracted. The most important are:msg_.externalData.magnetar on which the burst function is later called with specific magnetar calls (it is legitimate and whitelisted magnetar),msg_.user on whose behalf the further operation is called,msg_.externalData which is forwarder to further call,msg_.removeAndRepayData which is forwarder to further call.Those parameters are used to prepare a call to exitPositionAndRemoveCollateral function from OptionModule module (defined in action’s id param).
burst function from magnetar contract is called and it executes the specific module depending on the _action.id:_checkSender function does not revert if the user is the sender or the sender is whitelisted.exitPositionAndRemoveCollateral function on behalf of the user (who is the victim).Note: This is only one of possible attack scenarios that exploits lack of _srcChainSender parameter validation.
HIGH – The attacker can execute functions from UsdoMarketReceiverModule module on behalf of any user.
Validate whether the user whose assets are being managed is the same address as the _srcChainSender parameter.
Meet Composable Security
Get throughly tested by the creators of Smart Contract Security Verification Standard
Let us help
Get throughly tested by the creators of Smart Contract Security Verification Standard