TrufVesting.cancelVesting calculates end of vesting incorrectly
The cancelVesting function incorrectly calculates the end of vesting by using only the distribution period after the cliff, ignoring the initial release period and cliff. As a result, the owner cannot cancel an ongoing vesting because the function reverts as if vesting had already finished.
UbiquitousComputing Follow with fnanni, nobody2018 and 1 other
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-12-truflation-judging/issues/11
Found by
UbiquitousComputing, fnanni, nobody2018, rvierdiiev
Summary
TrufVesting.cancelVesting calculates end of vesting incorrectly and because of that owner can't stop vesting for the account.
Vulnerability Detail
TrufVesting.cancelVesting function allows owner to stop vesting for some account.
In case if vesting already finished, then function reverts.
The problem is that vestingInfos[categoryId][vestingId].period is just period for token distribution after cliff.
As you can see in claimable function the vesting starts on startTime, then when initialReleasePeriod has passed, then initialRelease is distributed. Then after cliff has passed, only then final distribution starts.
Thus check if vesting already finished is incorrect in the TrufVesting.cancelVesting and it doesn't allow owner to cancel vesting when it is still going.
Impact
Ongoing vesting can't be canceled.
Code Snippet
Provided above
Tool used
Manual Review
Recommendation
This check should be correct.
if (userVesting.startTime + vestingInfos[categoryId][vestingId].initialReleasePeriod + vestingInfos[categoryId][vestingId].cliff + vestingInfos[categoryId][vestingId].period <= block.timestamp) {
revert AlreadyVested(categoryId, vestingId, user);
}
Discussion
ryuheimat
https://github.com/truflation/truflation-contracts/pull/4
mstpr
Nice catch by the Watson! Fix LGTM
ryuheimat
Merged
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 end-of-vesting check omits the initial release period and cliff, using only the post-cliff distribution period.
Impact
Ongoing vesting cannot be cancelled by the owner, so tokens may continue to be released when they should have been stopped.
What the attacker needed
Owner role; vesting still ongoing
The fix
The check should include the initial release period and cliff in addition to the distribution period; the project merged a fix.
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 vesting schedule releases tokens to a user over time. The cancel function is meant to stop that release early, but it checks the wrong end date, so it thinks the schedule is already over and refuses to cancel while tokens are still being released.
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.