Reorg attack on user’s Vault deployment and deposit may lead to theft of funds
The Vault contract is deployed using CREATE, so its address depends on the deployer's nonce. If a chain reorganisation removes the victim's deployment and deposit, an attacker can front-run the deployment to take control of the Vault at that address, then steal the victim's deposit.
Submitted by ljmanini
VaultDeployer deploys instances of the Vault contract using create, where the address derivation depends on the sender’s address (= VaultDeployer) and its nonce.
Although the system is intended to be deployed on Ethereum, there still have been instances of chain reorgs in its PoS era : ref.
The frequency and depth of reorgs only increases in alternative L1s and L2s such as polygon and optimism, where reorgs have reached 100+ block depth : ref.
Proof of Concept
In a scenario in which a user’s Vault deplyoment and deposit is included fully within a reorg, an attacker is able to frontrun the user’s Vault deployment, effectively stealing the Vault instance at that particular address, include the user’s deployment (which will deploy a new Vault at a new, unrelated address) and his deposit to the originally deployed Vault, and finally backrun the user’s deposit by pulling funds from the Vault.
In order to pull off this attack successfully, the attacker needs to take care of some details:
- When frontrunning the
Vaultdeployment, he must callVaultDeployer.deployVault()through a malicious contract under his control which implements the minimal interface to allow calls theVaultmakes to theVaultControllerto not revert. Notice that this maliciousVaultControllercould allow only deposits to go through in theVault, but disallow withdrawals by returningfalsewhenVaultattempts to callCONTROLLER.checkVaultwithinVault.withdrawERC20. - When frontrunning the
Vaultdeployment, the attacker must set theVault’s minter to the victim’s address, in order for the deposit to successfully go through within theVault.
Once the victim’s deposit has been executed, the attacker can chose to pull the user’s funds from the compromised Vault by calling Vault.controllerTransfer through his malicious VaultController
Given the high impact of this finding but its low likelihood, I’m submitting this as a medium severity issue.
Recommended Mitigation Steps
Deployments of Vault instances should be done employing create2 with a salt calculated based on id, minter and msg.sender.
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 use of CREATE for vault deployment, which makes the address depend on the deployer's nonce and therefore predictable and reusable after a reorg.
Impact
An attacker could steal a victim's deposit if a reorg fully removes the victim's vault deployment and deposit, though the report notes this is unlikely.
What the attacker needed
A chain reorg removes the victim's deployment and deposit; attacker can front-run transactions; attacker deploys a malicious contract
The fix
Vault instances should be deployed using create2 with a salt derived from the id, minter and msg.sender.
How it was found
- Wait for a reorg that removes the victim's vault deployment and deposit.
- Front-run the victim's deployment by calling deployVault through a malicious contract that implements a minimal VaultController interface.
- Set the vault's minter to the victim's address so the victim's deposit succeeds.
- Let the victim's deposit go through to the attacker-controlled vault.
- Call controllerTransfer through the malicious controller to pull the victim's funds.
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 blockchain reorganisation (reorg) can undo recent transactions. This report shows that if a user's vault creation and deposit are undone, an attacker can quickly create the vault first at the same address and then take the user's deposit.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.