Unable to claim vesting due to unbounded timelock loop
The vest() function in Vesting.sol does not check that the caller is the beneficiary, so anyone can add timelocks for any beneficiary. A malicious actor can repeatedly call vest() with tiny amounts to make the timelocks array very large, causing the claim() function's loop to exceed the gas limit and revert, making the vestment unclaimable.
Submitted by nathaniel, also found by WatchPug, leastwood, and pauliax
Impact
The timelocks for any beneficiary are unbounded, and can be vested by someone who is not the beneficiary. When the array becomes significantly big enough, the vestments will no longer be claimable for the beneficiary.
The vest() function in Vesting.sol does not check the beneficiary, hence anyone can vest for anyone else, pushing a new timelock to the timelocks[_beneficiary]. The _claimableAmount() function (used by claim() function), then loops through the timelocks[_beneficiary] to determine the amount to be claimed. A malicious actor can easy repeatedly call the vest() function with minute amounts to make the array large enough, such that when it comes to claiming, it will exceed the gas limit and revert, rendering the vestment for the beneficiary unclaimable. The malicious actor could do this to each beneficiary, locking up all the vestments.
Proof of Concept
- https://github.com/code-423n4/2021-11-bootfinance/blob/main/vesting/contracts/Vesting.sol#L81
- https://github.com/code-423n4/2021-11-bootfinance/blob/main/vesting/contracts/Vesting.sol#L195
- https://github.com/code-423n4/2021-11-bootfinance/blob/main/vesting/contracts/Vesting.sol#L148
Tools Used
Manual code review
Recommended Mitigation Steps
- Create a minimum on the vestment amounts, such that it won’t be feasible for a malicious actor to create a large amount of vestments.
- Restrict the vestment contribution of a beneficiary where
require(beneficiary == msg.sender)
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 vest() function lacks a check that the caller is the beneficiary, and the claimable amount calculation loops over an unbounded array of timelocks.
Impact
The beneficiary's vestment becomes unclaimable, and the attacker could do this to every beneficiary, locking up all vestments.
What the attacker needed
Attacker can call vest() for any beneficiary; no minimum vestment amount
The fix
The fix should add a minimum vestment amount and restrict vesting so that only the beneficiary can vest for themselves.
How it was found
- Call the vest() function repeatedly with very small amounts for a target beneficiary, adding many entries to the timelocks array.
- When the beneficiary later calls claim(), the _claimableAmount() function loops through the large array.
- The loop exceeds the gas limit and the claim transaction reverts, so the beneficiary cannot claim.
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 smart contract lets people lock up tokens and claim them later. The function that adds a new lock-up does not check who is calling it, so anyone can add a lock-up for anyone else. By adding many tiny lock-ups, an attacker makes the list so long that when the real owner tries to claim, the transaction runs out of gas and fails, so the tokens are stuck.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.