Skip to content
DoS Audit finding Intermediate

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.

nathaniel Follow

Originally disclosed on Code4rena

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

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)

chickenpie347 (Boot Finance) confirmed

The original report as published on Code4rena, by nathaniel. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

  1. Call the vest() function repeatedly with very small amounts for a target beneficiary, adding many entries to the timelocks array.
  2. When the beneficiary later calls claim(), the _claimableAmount() function loops through the large array.
  3. 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.

More from Boot Finance contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.