Skip to content
DoS Audit finding Intermediate

Possible DoS attack when creating Joins in Wand

The JoinFactory contract allows anyone to create a Join contract at a deterministic address using CREATE2, and an attacker can pre-deploy fake Joins for common assets to block the Wand from deploying the real ones. This causes a denial of service for the Wand's deployment process.

Yield Witch v2 contest

Originally disclosed on Code4rena

It is possible for an attacker to intendedly create a fake Join corresponding to a specific token beforehand to make Wand unable to deploy the actual Join, causing a DoS attack.

The address of Join corresponding to an underlying asset is determined as follows and thus unique:

Join join = new Join{salt: keccak256(abi.encodePacked(asset))}();

Besides, the function createJoin in the contract JoinFactory is permissionless: Anyone can create the Join corresponding to the asset. An attacker could then deploy many Joins with different common underlying assets (e.g., DAI, USDC, ETH) before the Wand deploying them. The attempt of deploying these Joins by Wand would fail since the attacker had occupied the desired addresses with fake Joins, resulting in a DoS attack.

Moreover, the attacker can also perform DoS attacks on newly added assets: He monitors the mempool to find transactions calling the function addAsset of Wand and front-runs them to create the corresponding Join to make the benign transaction fail.

Referenced code: JoinFactory.sol#L64-L75 Wand.sol#L53

Recommend enabling access control in createJoin (e.g., adding the auth modifier) and allowing Wand to call it.

albertocuestacanada (Yield) confirmed:

The issue exists, and we appreciate raising it.

The solution can’t be adding auth to createJoin, since anyone can use CREATE2 to deploy a Join with their own factory, but with our Join bytecode, occupying the same address we would.

The proper mitigation, in our opinion, is to ditch CREATE2 and deploy Joins using CREATE instead.

As for the risk, such a DoS attack wouldn’t cause a loss of funds or an interruption on user service. It would cause a governance action to revert, which would be quickly fixed by deploying a new JoinFactory and replacing the Wand. Fortunately, no contract uses the Wand as a Join registry (maybe we should!).

I suggest the risk is downgraded to 1.

The original report as published on Code4rena. 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 CREATE2 with a salt derived only from the asset address, combined with a permissionless createJoin function, allows anyone to occupy the deterministic address before the legitimate deployment.

Impact

The attack could cause a denial of service by making Wand's deployment transactions revert, but according to the project it would not cause loss of funds or interrupt user service, and could be fixed by governance.

What the attacker needed

Attacker can call createJoin permissionlessly; Attacker can front-run transactions

The fix

The project suggests ditching CREATE2 and deploying Joins using CREATE instead, as adding access control to createJoin would not prevent the attack.

How it was found

  1. Attacker identifies common underlying assets (e.g., DAI, USDC, ETH).
  2. Attacker calls createJoin to deploy fake Joins for those assets before Wand does.
  3. When Wand attempts to deploy the real Joins, the transactions fail because the addresses are already taken.
  4. For new assets, attacker monitors the mempool for addAsset transactions and front-runs them to create the corresponding Join, causing the benign transaction to fail.

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.

A smart contract called JoinFactory lets anyone create a 'Join' contract for a given asset. The address of each Join is fixed in advance, so an attacker can create a fake Join first and take that address. When the legitimate system (Wand) later tries to create the real Join, it fails because the address is already used, blocking normal operation.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More from Yield Witch v2 contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.