Skip to content
Business logic Audit finding Intermediate

PerAddressTrancheVestingMerkleDistributor.claim always reverts because it checks the Merkle proof incorrectly

The claim and initializeDistributionRecord functions of PerAddressTrancheVestingMerkleDistributor omit the tranches from the Merkle proof check, so the proof never matches and both functions always revert. An attacker cannot exploit this; the distributor is simply inoperable.

jkoppel Follow with samuraii77

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update-judging/issues/15

Found by

jkoppel, samuraii77

Summary

Both the claim and initializeDistributionRecord methods of PerAddressTrancheVestingMerkleDistributor do not include the tranches when checking the Merkle proof (and do not even accept the tranches as a parameter). Both methods therefore always revert, before the function body is even entered.

Vulnerability Detail

We know from PerAddressTrancheVestingMerkle that the Merkle trees for this kind of distributor include the list of tranches for each address (and also because they have to be; there's no other way to specify the tranches). However, PerAddressTrancheVestingMerkleDistributor omits the tranches when checking the Merkle proofs. The Merkle proofs therefore always revert.

Impact

PerAddressTrancheVestingMerkleDistributor is completely inoperable.

Code Snippet

Notice the lack of tranches here:

https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update/blob/main/contracts/packages/hardhat/contracts/claim/factory/PerAddressTrancheVestingMerkleDistributor.sol#L42-L58

Solidity
    function initializeDistributionRecord(
        uint256 index, // the beneficiary's index in the merkle root
        address beneficiary, // the address that will receive tokens
        uint256 amount, // the total claimable by this beneficiary
        bytes32[] calldata merkleProof
    ) external validMerkleProof(keccak256(abi.encodePacked(index, beneficiary, amount)), merkleProof) {
        _initializeDistributionRecord(beneficiary, amount);
    }

    function claim(
        uint256 index, // the beneficiary's index in the merkle root
        address beneficiary, // the address that will receive tokens
        uint256 totalAmount, // the total claimable by this beneficiary
        bytes32[] calldata merkleProof
    )
        external
        validMerkleProof(keccak256(abi.encodePacked(index, beneficiary, totalAmount)), merkleProof)

Contrast the code in PerAddressTrancheVestingMerkle, which checks the Merkle proof like this:

https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update/blob/main/contracts/packages/hardhat/contracts/claim/PerAddressTrancheVestingMerkle.sol#L45

Solidity
    validMerkleProof(keccak256(abi.encodePacked(index, beneficiary, amount, abi.encode(tranches))), merkleProof)

Tool used

Manual Review

Recommendation

Add the tranches parameter to both methods and check in the Merkle proof

Discussion

ArshaanB

Yes, tranches should be passed to validMerkleProof() in order to properly validate for these two functions in PerAddressTrancheVestingMerkleDistributor.sol.

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/SoftDAO/contracts/pull/49

sherlock-admin2

The Lead Senior Watson signed off on the fix.

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

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 Merkle proof is computed over index, beneficiary and amount only, omitting the tranches that are part of the leaf in the corresponding Merkle tree.

Impact

The distributor is completely inoperable; no tokens can be claimed or distribution records initialised.

What the attacker needed

None

The fix

The tranches parameter should be added to both functions and included in the Merkle proof check; the text states the protocol team fixed this issue.

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 proof is a short piece of data that proves an entry belongs to a larger list without revealing the whole list. Here the list includes each address's tranches (payment schedules), but the code checks the proof without those tranches, so the check always fails and the function stops with an error.

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 jkoppel

View all

4 more disclosed reports, best first.

More from Tokensoft Distributor Contracts Update

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.