Skip to content
Business logic Audit finding Intermediate

Verification should be leafed based and not address based

The Merkle vesting and drop contracts track claims by claimant address rather than by Merkle leaf, so when a tree contains several leaves for the same address only one claim is ever possible. The report frames this as an unclear intended behaviour rather than a direct theft, and the team confirmed it and resolved it by clarifying the documentation.

Picodes Follow

Originally disclosed on Code4rena

Submitted by Picodes, also found by pedroais, and unforgiven

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/MerkleVesting.sol#L115

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/MerkleDropFactory.sol#L92

Impact

Contracts should clarify what is the intended behavior for Merkle trees with multiple leafs with the same address.

Recommended Mitigation Steps

There is 2 possible behaviors:

  • either - what is currently done - you only authorize one claim per address, in which case the multiple leaf are here to give users a choice - for example you could use MerkleVesting to give users the choice between 2 sets of vesting parameters and have something close to MerkleResistor.
  • either you use a mapping based on the leaf to store if a leaf has been claimed or not.

This behavior should be clarified in the comments at least, and made clear to merkle tree builders.

illuzen (FactoryDAO) confirmed, disagreed with severity and commented:

This is covered in a comment on MerkleResistor:49, but we should put it elsewhere for clarity.

illuzen (FactoryDAO) resolved:

https://github.com/code-423n4/2022-05-factorydao/pull/3


The original report as published on Code4rena, by Picodes. 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 claim check keys on the claimant address rather than on the specific Merkle leaf, so duplicate-address leaves collapse into a single claim.

Impact

A user with several leaves for the same address can only claim once, so the extra allocations are effectively lost; the text does not claim any attacker can steal funds.

What the attacker needed

A Merkle tree with duplicate-address leaves

The fix

The team resolved it by clarifying the intended behaviour in the contract comments and documentation for Merkle tree builders.

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 Merkle tree is a way to prove that a piece of data belongs to a published list without storing the whole list on chain. Here each entry in the list is a claim, and the contract remembers claims by the wallet address instead of by the entry itself. If one wallet appears in several entries, only the first claim succeeds and the rest are silently blocked.

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 Picodes

View all

17 more disclosed reports, best first.

More from FactoryDAO contest

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.