if the Virtual Account’s owner is a Contract Account (multisig wallet), attackers can gain control of the Virtual Accounts by gaining control of the same owner’s address in a different chain
The RootPort contract fetches a virtual account using only the caller's address from the source branch, without considering which branch the call came from. An attacker who controls the same address on a different chain could access and withdraw assets from the virtual account.
Submitted by 0xStalin, also found by ladboy233 and hals
Attackers can gain control of User’s Virtual Accounts and steal all the assets in these accounts held in the Root environment.
Proof of Concept
- When sending signed messages from a Branch to Root, the RootBridgeAgent contract calls the
RootPort::fetchVirtualAccount()to get the Virtual Account that is assigned in the Root environment to the address who initiated the call in the SrcBranch; if that address doesn’t have an assigned Virtual Account yet, it proceeds to create one and assign it. - The problem is that the
fetchVirtualAccount()function solely relies on the address of the caller in the SrcBranch; however, it doesn’t take into account from which Branch the call comes.
BranchBridgeAgent.sol:
function callOutSignedAndBridge(
...
) external payable override lock {
...
//Encode Data for cross-chain call.
bytes memory payload = abi.encodePacked(
_hasFallbackToggled ? bytes1(0x85) : bytes1(0x05),
//@audit-info => Encodes the address of the caller in the Branch and sends it to the RootBridgeAgent
//@audit-info => This address will be used to fetch the VirtualAccount assigned to it!
msg.sender,
_depositNonce,
_dParams.hToken,
_dParams.token,
_dParams.amount,
_dParams.deposit,
_params
);
}
RootBridgeAgent.sol:
function lzReceiveNonBlocking(
...
) public override requiresEndpoint(_endpoint, _srcChainId, _srcAddress) {
...
...
...
else if (_payload[0] == 0x04) {
// Parse deposit nonce
nonce = uint32(bytes4(_payload[PARAMS_START_SIGNED:PARAMS_TKN_START_SIGNED]));
//Check if tx has already been executed
if (executionState[_srcChainId][nonce] != STATUS_READY) {
revert AlreadyExecutedTransaction();
}
//@audit-info => Reads the address of the msg.sender in the BranchBridgeAgent and forwards that address to the RootPort::fetchVirtualAccount()
// Get User Virtual Account
VirtualAccount userAccount = IPort(localPortAddress).fetchVirtualAccount(
address(uint160(bytes20(_payload[PARAMS_START:PARAMS_START_SIGNED])))
);
// Toggle Router Virtual Account use for tx execution
IPort(localPortAddress).toggleVirtualAccountApproved(userAccount, localRouterAddress);
...
...
}
...
...
}
RootPort.sol:
//@audit-info => Receives from the RootBridgeAgent contract the address of the caller in the BranchBridgeAgent contract
//@audit-info => Fetches the VirtualAccount assigned to the _user address regardless from what Branch the call came from
function fetchVirtualAccount(address _user) external override returns (VirtualAccount account) {
account = getUserAccount[_user];
if (address(account) == address(0)) account = addVirtualAccount(_user);
}
Like the example, let’s suppose that a user uses a MultiSigWallet contract to deposit tokens from Avax to Root, in the RootBridgeAgent contract. The address of the MultisigWallet will be used to create a Virtual Account, and all the globalTokens that were bridged will be deposited in this Virtual Account.
Now, the problem is that the address of the MultisigWallet, might not be controlled by the same user on a different chain. For example, in Polygon, an attacker could gain control of the address of the same address of the MultisigWallet that was used to deposit tokens from Avax in the Root environment. An attacker can send a signed message from Polygon, using the same address of the MultisigWallet that deposited tokens from Avax, to the Root environment, requesting to withdraw the assets that the Virtual Account is holding in the Root environment to the Polygon Branch.
When the message is processed by the Root environment, the address that will be used to obtain the Virtual Account will be the address that initiated the call in Polygon; which will be the same address of the user’s MultisigWallet contract who deposited the assets from Avax. However, the Root environment, when fetching the virtual account, makes no distinctions between the branches. Thus, it will give access to the Virtual Account of the attacker’s caller address and process the message in the Root environment.
As a result, an attacker can gain control of the Virtual Account of an account contract that was used to deposit assets from a chain into Root, by gaining control of the same address of the account contract that deposited the assets in a different chain.
As explained in detail on this article written by Rekt, it is possible to gain control of the same address for contract accounts in a different chain; especially for those contract accounts that are deployed using the Gnosis Safe contracts:
Recommended Mitigation Steps
The recommendation is to add some logic that validates if the caller address in the BranchBridgeAgent is a contract account or an EOA. If it’s a contract account, send a special flag as part of the crosschain message, so that the RootBridgeAgent contract can know if the caller in the SrcBranch it’s a contract or an EOA.
- If the caller is an EOA, the caller’s address can be assigned as the Virtual Account owner on all the chains, for EOAs there are no problems.
- But, if the caller is a Contract Account, when fetching the virtual account forward to the SrcChain, and if a Virtual Account is created, authorize the caller address on the SrcBranch as the owner for that Virtual Account. This way, only the contract account in the SrcBranch can access the Virtual Account in the Root environment.
Make sure to use the srcChainId to validate if the caller is an owner of the Virtual Account.
Assessed type
Access Control
Contracts should not use Virtual Accounts and deploying a specific router for contract usage is most likely the safest option.
alcueca (judge) increased severity to High and commented:
This is related to #351 in the wrong assumption that a given address is controlled by the same individual in all chains. There are different attack vectors and impacts, but fixing that core assumption will solve all of them.
The underlying issue is assuming that the same addresses are controlled by the same people in different chains, which is not necessarily true. While the sponsor states that contracts should not use virtual accounts, that is not specified in the documentation, and might only have been discovered in a future issue of rekt.
@alcueca - While I appreciate the in-depth analysis presented in the report, there’s a fundamental discrepancy when it comes to the exploitability of the vulnerability mentioned.
The report suggests that on Polygon, an attacker could simply gain control of an address identical to the MultiSigWallet from Avax. However, referring to a recent real-world scenario as detailed in the Wintermute incident, we observe that this assumption may be oversimplified.
The Wintermute incident underscores the intricacies and challenges involved in gaining control of a similar address on a different chain:
- The address would have to be unclaimed or unused on the target chain.
- Assuming the MultiSigWallet is used across multiple chains, the rightful owners might have already claimed the address.
- Even if the address is unclaimed, there are intricate steps involving replicating nonce values and other parameters to “hijack” the address, and this is far from being straightforward.
Given these complexities and the potential for failure, it’s crucial to approach the reported vulnerability with a nuanced understanding of its practical exploitability.
Agree with the above comments, that there may be some efforts involved to gain control the same address. The wrong assumption that the same address is controlled by same person when using smart contract wallet does cost Wintermute to lose 20M OP token.
Once funds are lost, the loss amount is large.
In the case of wintermute, the multisig wallet is created using the opcode “CREATE” instead of “CREATE2”. The create opcode is not really deprecated, and still be used.
More info about the CREATE opcode here and deterministic addresses.
Agree with high severity because the potential loss of funds is large.
There is a significant chance of actual losses because of this vulnerability, that don’t need to be enabled by any unlikely prior. The severity is High.
Addressed here.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the system assumes that the same address is controlled by the same entity across all chains, and the virtual account lookup does not include the source chain ID.
Impact
An attacker could gain control of the virtual account and steal all assets held in the Root environment, but the attack requires gaining control of the same contract address on another chain, which may be difficult.
What the attacker needed
Victim uses a contract account (e.g., multisig) to deposit; attacker gains control of same address on another chain
The fix
The fix should validate whether the caller is a contract account and, if so, use the source chain ID to ensure only the contract on that specific chain can access the virtual account.
How it was found
- A user uses a multisig contract wallet to deposit tokens from one chain (e.g., Avax) to the Root environment, creating a virtual account owned by that contract address.
- An attacker gains control of the same contract address on a different chain (e.g., Polygon).
- The attacker sends a signed message from that chain to the Root environment, requesting to withdraw the assets held in the virtual account.
- The Root environment fetches the virtual account using the attacker's caller address, which matches the victim's contract address, and processes the withdrawal.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A virtual account is a smart contract that holds assets for a user on one blockchain. The system assumed that if the same address appears on two different blockchains, it is controlled by the same person. But for contract accounts, an attacker can sometimes deploy a contract at the same address on another chain and then use it to access the victim's virtual account.
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.