Skip to content
Business logic Audit finding Advanced

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

https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/VaultFactory.sol#L67-L78

  1. Bob setup a bot to monitor the mempool when PT deploys a new vault.
  2. Bob’s bot saw a deployment by PT at 0x1234 and fires a tx to deposit immediately.
  3. Alice front-runs PT’s deployment by deploying a malicious vault at 0x1234.
  4. 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?

Picodes (judge) commented:

@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.

PoolTogether mitigated:

Used CREATE2 for VaultFactory. PR: https://github.com/GenerationSoftware/pt-v5-vault/pull/25

Status: Mitigation confirmed. Full details in reports from dirk_y, rvierdiiev and 0xStalin.


The original report as published on Code4rena, by gzeon. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

  1. Bob sets up a bot to watch the mempool for new vault deployments.
  2. Bob's bot sees PT's deployment at a known address and sends a deposit transaction.
  3. Alice front-runs PT's deployment by deploying a malicious vault at the same address.
  4. 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.

More by gzeon

View all

46 more disclosed reports, best first.

More from PoolTogether

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.