Skip to content
Business logic Audit finding Intermediate

_releaseIntervalSecs is not validated

The smart contract function that creates vesting claims does not validate the release interval against the linear vest amount and timestamps, allowing an admin to set an incorrect interval. This could cause unfair token distributions or make the final withdrawal revert.

sorrynotsorry Follow

Originally disclosed on Code4rena

Submitted by sorrynotsorry

VTVLVesting.sol has _createClaimUnchecked function to create the claims internally while validating parameters with the users’ allocations. However, _releaseIntervalSecs is not validated comparing to user’s _linearVestAmount and _startTimestamp _endTimestamp. Theoretically, _linearVestAmount should be equal to ((_endTimestamp - _startTimestamp) * _releaseIntervalSecs) so the _releaseIntervalSecs = _linearVestAmount / ((_endTimestamp - _startTimestamp). But this check was never done.

If the _releaseIntervalSecs is validated either to a higher or to a lower amount, it will create unfair distributions amongst the users during withdrawals due to being higher/lower than it should be. And also it may end up with the last withdrawals can be reverted due to the calculation board not matching.

Proof of Concept

    function _createClaimUnchecked(
            address _recipient,
            uint40 _startTimestamp,
            uint40 _endTimestamp,
            uint40 _cliffReleaseTimestamp,
            uint40 _releaseIntervalSecs,
            uint112 _linearVestAmount,
            uint112 _cliffAmount
                ) private  hasNoClaim(_recipient) {

        require(_recipient != address(0), "INVALID_ADDRESS");
        require(_linearVestAmount + _cliffAmount > 0, "INVALID_VESTED_AMOUNT"); // Actually only one of linearvested/cliff amount must be 0, not necessarily both
        require(_startTimestamp > 0, "INVALID_START_TIMESTAMP");
        // Do we need to check whether _startTimestamp is greater than the current block.timestamp?
        // Or do we allow schedules that started in the past?
        // -> Conclusion: we want to allow this, for founders that might have forgotten to add some users, or to avoid issues with transactions not going through because of discoordination between block.timestamp and sender's local time
        // require(_endTimestamp > 0, "_endTimestamp must be valid"); // not necessary because of the next condition (transitively)
        require(_startTimestamp < _endTimestamp, "INVALID_END_TIMESTAMP"); // _endTimestamp must be after _startTimestamp
        require(_releaseIntervalSecs > 0, "INVALID_RELEASE_INTERVAL");
        require((_endTimestamp - _startTimestamp) % _releaseIntervalSecs == 0, "INVALID_INTERVAL_LENGTH");

        // Potential TODO: sanity check, if _linearVestAmount == 0, should we perhaps force that start and end ts are the same?

        // No point in allowing cliff TS without the cliff amount or vice versa.
        // Both or neither of _cliffReleaseTimestamp and _cliffAmount must be set. If cliff is set, _cliffReleaseTimestamp must be before or at the _startTimestamp
        require(
            (
                _cliffReleaseTimestamp > 0 &&
                _cliffAmount > 0 &&
                _cliffReleaseTimestamp <= _startTimestamp
            ) || (
                _cliffReleaseTimestamp == 0 &&
                _cliffAmount == 0
        ), "INVALID_CLIFF");

        Claim memory _claim = Claim({
            startTimestamp: _startTimestamp,
            endTimestamp: _endTimestamp,
            cliffReleaseTimestamp: _cliffReleaseTimestamp,
            releaseIntervalSecs: _releaseIntervalSecs,
            cliffAmount: _cliffAmount,
            linearVestAmount: _linearVestAmount,
            amountWithdrawn: 0,
            isActive: true
        });
        // Our total allocation is simply the full sum of the two amounts, _cliffAmount + _linearVestAmount
        // Not necessary to use the more complex logic from _baseVestedAmount
        uint112 allocatedAmount = _cliffAmount + _linearVestAmount;

        // Still no effects up to this point (and tokenAddress is selected by contract deployer and is immutable), so no reentrancy risk
        require(tokenAddress.balanceOf(address(this)) >= numTokensReservedForVesting + allocatedAmount, "INSUFFICIENT_BALANCE");

        // Done with checks

        // Effects limited to lines below
        claims[_recipient] = _claim; // store the claim
        numTokensReservedForVesting += allocatedAmount; // track the allocated amount
        vestingRecipients.push(_recipient); // add the vesting recipient to the list
        emit ClaimCreated(_recipient, _claim); // let everyone know
    }

Permalink

Recommended Mitigation Steps

The _releaseIntervalSecs should be validated comparing to user’s _linearVestAmount and _startTimestamp _endTimestamp.

0xean (judge) decreased severity to Medium and commented:

This is fair, but due to it being behind only admin functionality and coming down to input sanitization, going to downgrade to Medium.

lawrencehui (VTVL) acknowledged, but disagreed with severity and commented:

I agree with @0xean that the risk in this case is low given the onlyAdmin modifier and the input will be validated from the frontend anyway. Appreciate the finding and we will take consideration of adding additional checking of _releaseIntervalSecs.


The original report as published on Code4rena, by sorrynotsorry. 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 function `_createClaimUnchecked` does not verify that `_linearVestAmount` equals `(_endTimestamp - _startTimestamp) * _releaseIntervalSecs`, so an inconsistent interval can be stored.

Impact

An admin could create unfair vesting schedules or cause the last withdrawal to revert, but the issue is limited to admin-only functionality and the frontend is expected to validate input.

What the attacker needed

Admin privileges; frontend validation bypassed

The fix

The `_releaseIntervalSecs` should be validated against the linear vest amount and start/end timestamps.

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 to users over time. The code that sets up a user's schedule forgot to check that the release interval matches the total amount and duration, so a mistake could give users the wrong amount or break the last withdrawal.

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.

More by sorrynotsorry

View all

4 more disclosed reports, best first.

More from VTVL contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.