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
Recommended Mitigation Steps
Deploy such contracts via create2 with salt that includes msg.sender.
asselstine (PoolTogether) confirmed via duplicate issue #169
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.
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
- Alice deploys a new VaultBooster and sends funds to it.
- A network block reorg occurs.
- Bob calls createVaultBooster, creating a VaultBooster at the address Alice used.
- 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.