New vest reset unlockBegin of existing vest without removing vested amount
The vesting contract resets the unlock schedule when new tokens are vested, but does not reset the claimed amount, so a user who has already claimed some tokens can have their claimable balance underflow and revert. This locks their previously vested tokens until the new schedule completes.
Submitted by gzeon, also found by cccz, TrungOre, minhquanym, cmichel, 0xDjango, and rayn
Impact
When vest is called by xCTDL vault, the previous amount will re-lock according to the new vesting timeline. While this is as described in L127, claimableBalance might revert due to underflow if vesting[recipient].claimedAmounts > 0 because the user will need to vest the claimedAmounts again which should not be an expected behavior as it is already vested.
Proof of Concept
vesting[recipient].lockedAmounts =
vesting[recipient].lockedAmounts +
_amount;
vesting[recipient].unlockBegin = _unlockBegin;
vesting[recipient].unlockEnd = _unlockBegin + vestingDuration;
uint256 locked = vesting[recipient].lockedAmounts;
uint256 claimed = vesting[recipient].claimedAmounts;
if (block.timestamp >= vesting[recipient].unlockEnd) {
return locked - claimed;
}
return
((locked * (block.timestamp - vesting[recipient].unlockBegin)) /
(vesting[recipient].unlockEnd -
vesting[recipient].unlockBegin)) - claimed;
Recommended Mitigation Steps
Reset claimedAmounts on new vest
vesting[recipient].lockedAmounts =
vesting[recipient].lockedAmounts -
vesting[recipient].claimedAmounts +
_amount;
vesting[recipient].claimedAmounts = 0
vesting[recipient].unlockBegin = _unlockBegin;
vesting[recipient].unlockEnd = _unlockBegin + vestingDuration;
shuklaayush (BadgerDAO) confirmed and commented:
I think this is valid and was fixed in https://github.com/Citadel-DAO/citadel-contracts/pull/44
jack-the-pug (judge) decreased severity to Medium and commented:
I’m downgrading this to Medium as there are no funds directly at risk, but a malfunction and leak of value. The user will have to wait for a longer than expected time to claim their vested funds.
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 vest function updates lockedAmounts and the unlock schedule but leaves claimedAmounts unchanged, so the claimable calculation subtracts previously claimed tokens from a newly locked amount that does not include them.
Impact
The user cannot claim their previously vested tokens until the new vesting period ends, causing a delay and a leak of value, but no funds are directly at risk.
What the attacker needed
User has previously claimed some vested tokens; xCTDL vault calls vest again for the same user
The fix
The vest function should subtract the claimed amount from lockedAmounts and reset claimedAmounts to zero when a new vest is started; the report says this was fixed in a later pull request.
How it was found
- A user vests some tokens and claims part of them, so claimedAmounts is greater than zero.
- The xCTDL vault calls vest again for the same recipient with a new unlockBegin.
- The contract adds the new amount to lockedAmounts and resets unlockBegin and unlockEnd, but does not reset claimedAmounts.
- When the user calls claimableBalance, the calculation subtracts the old claimedAmounts from the new locked amount, causing an underflow and revert.
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 contract gradually releases tokens over time. When new tokens are added, the contract restarts the release schedule but forgets to reset how many tokens the user has already claimed. This makes the contract think the user has claimed more than is available, so it refuses to release any more tokens until the new schedule finishes.
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.