An attacker can front-run deployVault to deploy at the same address
The vault factory used CREATE1, so a vault's address depended only on the factory's nonce. An attacker could front-run a deployment or exploit a chain reorg to place a malicious vault at the same address, causing users' deposits to go to the attacker's vault.
gzeon Follow with Inspecktor, Breeje and 2 others
Originally disclosed on Code4rena
Submitted by gzeon, also found by Inspecktor, Breeje, 0xMirce, and ptsanev
Vaults are created from the factory via CREATE1. An attacker can front-run deployVault to deploy at the same address, but with different config. If the deployed chain reorg, a different vault might also be deployed at the same address.
Proof of Concept
- Bob setup a bot to monitor the
mempoolwhen PT deploys a new vault. - Bob’s bot saw a deployment by PT at
0x1234and fires a tx to deposit immediately. - Alice front-runs PT’s deployment by deploying a malicious vault at
0x1234. - Bob’s transaction ended up deposited into Alice’s malicious vault.
Recommended Mitigation Steps
Use CREATE2 and the vault config as salt.
Assessed type
MEV
asselstine (PoolTogether) disputed and commented:
The Vault address is a derivative of the (sender address, nonce). I don’t see how this scenario is possible?
@asselstine - exactly. Here, it only depends on the nonce of the factory; so in case of reorg, someone could “override” a vault deployment and all following transactions would still be executed.
Used
CREATE2forVaultFactory. PR: https://github.com/GenerationSoftware/pt-v5-vault/pull/25
Status: Mitigation confirmed. Full details in reports from dirk_y, rvierdiiev and 0xStalin.
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
The factory used CREATE1, making the vault address depend only on the factory's nonce, which an attacker could control via front-running or a reorg.
Impact
An attacker could cause user deposits to go to a malicious vault, and a chain reorg could also result in a different vault at the same address.
What the attacker needed
Attacker can front-run deployment; or a chain reorg occurs; victim deposits to expected address
The fix
The factory was changed to use CREATE2 with the vault config as salt, and the mitigation was confirmed.
How it was found
- Bob sets up a bot to watch the mempool for new vault deployments.
- Bob's bot sees PT's deployment at a known address and sends a deposit transaction.
- Alice front-runs PT's deployment by deploying a malicious vault at the same address.
- Bob's deposit ends up in Alice's malicious vault.
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.
When a contract creates another contract, the new contract's address is usually derived from the creator's address and a counter (nonce). If someone else can make a transaction with the same nonce first, they can occupy that address with their own contract. Here, an attacker could deploy a fake vault at the address users expected, so their deposits went to the attacker.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.