Skip to content
Race condition Audit finding Advanced

Create methods are suspicious of the reorg attack

The VaultBoosterFactory contract uses CREATE to deploy new VaultBooster contracts, so the deployed address depends only on the factory's nonce. An attacker could exploit a blockchain reorganisation to deploy a contract at the same address that a victim had pre-computed and funded, potentially stealing the victim's funds.

MohammedRizwan Follow with MohammedRizwan, nadin and 1 other

Originally disclosed on Code4rena

Submitted by MohammedRizwan, also found by MohammedRizwan, nadin, and ptsanev

The createVaultBooster() function deploys a new VaultBooster contract using the create, where the address derivation depends only on the VaultBoosterFactory nonce.

Re-orgs can happen in all EVM chains and as confirmed the contracts will be deployed on most EVM compatible L2s including Arbitrum, etc. It is also planned to be deployed on ZKSync in future. In ethereum, where this is deployed, Re-orgs has already been happened. For more info, check here.

This issue will increase as some of the chains like Arbitrum and Polygon are suspicious of the reorg attacks.

Polygon re-org reference: click here. This one happened this year in February, 2023.

Polygon blocks forked: check here

The issue would happen when users rely on the address derivation in advance or try to deploy the position clone with the same address on different EVM chains, any funds sent to the new contract could potentially be withdrawn by anyone else. All in all, it could lead to the theft of user funds.

File: src/VaultBoosterFactory.sol

    function createVaultBooster(PrizePool _prizePool, address _vault, address _owner) external returns (VaultBooster) {
>>        VaultBooster booster = new VaultBooster(_prizePool, _vault, _owner);

        emit CreatedVaultBooster(booster, _prizePool, _vault, _owner);

        return booster;
    }

Optimistic rollups (Optimism/Arbitrum) are also suspect to reorgs since if someone finds a fraud the blocks will be reverted, even though the user receives a confirmation.

Attack Scenario Imagine that Alice deploys a new VaultBooster, and then sends funds to it. Bob sees that the network block reorg happens and calls createVaultBooster. Thus, it creates VaultBooster with an address to which Alice sends funds. Then Alices’ transactions are executed and Alice transfers funds to Bob’s controlled VaultBooster.

This is a Medium severity issue that has been referenced from below Code4rena reports: https://code4rena.com/reports/2023-01-rabbithole/#m-01-questfactory-is-suspicious-of-the-reorg-attack https://code4rena.com/reports/2023-04-frankencoin#m-14-re-org-attack-in-factory

Proof of Concept

https://github.com/GenerationSoftware/pt-v5-vault-boost/blob/9d640051ab61a0fdbcc9500814b7f8242db9aec2/src/VaultBoosterFactory.sol#L29

Recommended Mitigation Steps

Deploy such contracts via create2 with salt that includes msg.sender.

asselstine (PoolTogether) confirmed via duplicate issue #169

hickuphh3 (judge) commented:

Accepting because of this:

“Imagine that Alice deploys a new VaultBooster, and then sends funds to it. Bob sees that the network block reorg happens and calls createVaultBooster. Thus, it creates VaultBooster with an address to which Alice sends funds. Then Alices’ transactions are executed and Alice transfers funds to Bob’s controlled VaultBooster.”

Again, the scenario should have been more explicit: stating how the vault could be different, how funds are transferred & possibly exploited.


The original report as published on Code4rena, by MohammedRizwan. 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

Likely the use of CREATE (which derives the address from the factory's nonce) instead of CREATE2 with a salt that includes the caller, making the deployed address predictable and vulnerable to reorg-based front-running.

Impact

If a reorg occurs, funds sent to a pre-computed VaultBooster address could be stolen by an attacker who deploys a contract at that address first.

What the attacker needed

A blockchain reorg occurs; victim pre-computes address and sends funds; attacker monitors and deploys during reorg

The fix

The contracts should be deployed using CREATE2 with a salt that includes msg.sender.

How it was found

  1. Alice deploys a new VaultBooster and sends funds to it.
  2. A network block reorg occurs.
  3. Bob calls createVaultBooster, creating a VaultBooster at the address Alice used.
  4. Alice's transactions are executed and her funds go to Bob's controlled VaultBooster.

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 smart contract creates another contract, the new contract's address is often calculated from the creator's address and a counter. If the blockchain briefly reorganises (a 'reorg'), some transactions can be reordered or replaced. This report says that because the address depends only on a counter, an attacker could jump in during a reorg and create a contract at the same address the victim expected, then take any funds sent there.

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.

More from PoolTogether

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.