LinearVesting does not calculate vested amount linearly
The linear vesting contract calculates the claimable amount incorrectly, so after a partial claim the user receives less than the correct linear share. An attacker or user could claim less than entitled, but the text does not describe an exploit to steal funds.
Submitted by xYrYuYx
Impact
- https://github.com/code-423n4/2021-11-vader/blob/main/contracts/tokens/vesting/LinearVesting.sol#L261
- https://github.com/code-423n4/2021-11-vader/blob/main/contracts/tokens/vesting/LinearVesting.sol#L294
These calculations are incorrect for linear vesting.
Proof of Concept
i.e. if start amount is 10000, and duration is 100 seconds. After 50 seconds, user can claim 5000 which is 50%
After another 10 seconds, user need to claim 1000 which is 10%, but current calculation return 500.
Tools Used
Manual
Recommended Mitigation Steps
Change formula to User total amount * (block.timestamp – start) / (vesting duration) – user claimed amount.
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 formula subtracts the already claimed amount from the wrong base or applies the percentage to the remaining amount instead of the total vested amount.
What the attacker needed
A vesting schedule with partial claims
How it was found
- Set start amount to 10000 and duration to 100 seconds.
- After 50 seconds, claim 5000 (50%).
- After another 10 seconds, the correct claimable amount is 1000 (10%), but the contract returns 500.
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 releases tokens gradually over time. This one miscalculates how many tokens are available after a partial claim, giving the user too few tokens. The report shows a simple example where the user should get 1000 but gets 500.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.