# Reorg attack on user's Vault deployment and deposit may lead to theft of funds

VaultDeployer uses CREATE so a reorg lets an attacker frontrun a victim's Vault deployment, capture the address, and steal their deposit.

- Payout: Contest reward
- Severity: medium
- Program: Amphora Protocol
- Credited: ljmanini
- Disclosed: 2024-04-22
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2023-07-amphora-findings/issues/233
- Library page: https://bugbountylibrary.com/r/c4%3A2023-07-amphora%3AM-02
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:race-window vuln:business-logic

**Target:** VaultDeployer / Vault contract deployment
**Root cause:** Vault instances are deployed with CREATE, so the address depends only on VaultDeployer's address and nonce; a reorg lets an attacker occupy that nonce/address first with a malicious controller.
**Steps:**
1. Victim's deployVault + deposit tx is included in a block that gets reorged out.
2. Attacker frontruns by calling `VaultDeployer.deployVault()` via a malicious contract implementing a fake VaultController that returns true for deposits and false for `checkVault` in withdrawERC20.
3. Attacker sets the Vault's minter to the victim's address so the victim's deposit succeeds.
4. Victim's original deploy tx re-executes, deploying a new Vault at a different address, but the deposit lands in the attacker-controlled Vault.
5. Attacker calls `Vault.controllerTransfer` via the malicious controller to pull the victim's funds.
**How found:** Reasoned about CREATE address derivation (sender+nonce) and known reorg depths on Ethereum PoS/L2s, hypothesizing an attacker could occupy the deterministic address before the victim's re-executed tx.
**Exploitation:** Requires a chain reorg covering the victim's deploy+deposit. Attacker races to deploy at the same CREATE address with a malicious controller, sets minter to victim, lets deposit land, then drains via controllerTransfer.
**Insight:** When a factory uses CREATE, the deployed address is predictable from factory nonce; on reorg-prone chains an attacker can squat that address with a hostile implementation and redirect the victim's follow-up calls/deposits.
