AdvancedDistributorInitializable sets claim data to empty, making claims fail
The AdvancedDistributorInitializable contract overrides the claim data with an empty byte array, causing claims to fail for PerAddressTrancheVestingMerkleDistributor and PerAddressContinuousVestingMerkleDistributor because their getVestedFraction functions attempt to decode this data and revert when it is empty.
0xboriskataa Follow with 1337web3, BiasedMerc and 10 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update-judging/issues/11
Found by
0xboriskataa, 1337web3, BiasedMerc, Honour, Ironsidesec, Varun_05, aman, hunter_w3b, jkoppel, merlin, nfmelendez, robertodf, samuraii77
Summary
AdvancedDistributorInitializable.claim overrides the passed-in data with new bytes(0). This data is needed by both PerAddressTrancheVestingMerkleDistributor and PerAddressContinuousVestingMerkleDistributor for claims to work. Therefore, claims do not work.
Vulnerability Detail
Impact
Claims do not work
Both PerAddressTrancheVestingMerkleDistributor and PerAddressContinuousVestingMerkleDistributor also pass in new bytes(0) to this argument, causing the same issue. However, this is a separate issue per my understanding of Sherlock rules; it is in separate code, and will stay broken if the others are fixed.
Code Snippet
AdvancedDistributorInitializable calls DistributorInitializable._executeClaim with data=new bytes(0)
function _executeClaim(address beneficiary, uint256 totalAmount, bytes memory)
internal
virtual
override
returns (uint256 _claimed)
{
_claimed = super._executeClaim(beneficiary, totalAmount, new bytes(0));
_reconcileVotingPower(beneficiary);
}
DistributorInitializable._executeClaim forwards this data to getClaimableAmount, which forwards it to getVestedFraction
https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update/blob/main/contracts/packages/hardhat/contracts/claim/factory/DistributorInitializable.sol#L75 https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update/blob/main/contracts/packages/hardhat/contracts/claim/factory/DistributorInitializable.sol#L113
Many implementations of getVestedFraction attempt to decode this data in ways that break if the data is empty.
E.g.:
function getVestedFraction(
address beneficiary,
uint256 time, // time is in seconds past the epoch (e.g. block.timestamp)
bytes memory data
) public view override returns (uint256) {
(uint256 start, uint256 cliff, uint256 end) = abi.decode(data, (uint256, uint256, uint256));
Putting these together, attempting to claim will be a lot like this Chisel section.
➜ bytes memory data = new bytes(0)
➜ (uint256 start, uint256 cliff, uint256 end) = abi.decode(data, (uint256, uint256, uint256));
Traces:
[805] 0xBd770416a3345F91E4B34576cb804a576fa48EB1::run()
└─ ← "EvmError: Revert"
⚒️ Chisel Error: Failed to execute REPL contract!
Tool used
Manual Review
Recommendation
Pass the data parameter along properly
Discussion
ArshaanB
Yes, can confirm, this seems like an issue.
ContinuousVestingInitializable, TrancheVestingInitializable — the getVestedFraction() doesn't care about data
PerAddressContinuousVestingInitializable, PerAddressTrancheVestingInitializable — the getVestedFraction() does care about data
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/SoftDAO/contracts/pull/47
ArshaanB
An additional PR covering a case that I didn't cover in PR 47 above: https://github.com/SoftDAO/contracts/pull/51
ArshaanB
PR covering a case for PACVM https://github.com/SoftDAO/contracts/pull/52
sherlock-admin2
The Lead Senior Watson signed off on the fix.
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 AdvancedDistributorInitializable._executeClaim function overrides the data parameter with an empty byte array instead of forwarding the original data, which breaks downstream decoding in specific distributor implementations.
Impact
Claims do not work for PerAddressTrancheVestingMerkleDistributor and PerAddressContinuousVestingMerkleDistributor, preventing users from claiming their tokens.
What the attacker needed
None
The fix
The protocol team fixed this issue by passing the data parameter along properly in multiple pull requests.
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.
In a smart contract, a function that processes claims was ignoring the extra information (data) it was given and instead passing an empty value. Some claim types need that extra information to calculate how many tokens the user can claim, so when it was missing, the calculation failed and the claim could not go through.
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.