Skip to content
DoS Audit finding Intermediate

Possible DoS scenario when transferring vests to another address

Shubham Follow with ABAIKUNANBAEV

Originally disclosed on Code4rena

Submitted by Shubham, also found by ABAIKUNANBAEV

https://github.com/code-423n4/2024-12-secondswap/blob/main/contracts/SecondSwap_StepVesting.sol#L225

Vestings can be transferred to another address by a trusted authority. All the necessary parameters are recalculated like the totalAmount & releaseRate for the current owner for the vesting.

However it is possible that a call to transfer the vesting might be frontrun where the owner of the original vesting claims their token resulting in an overall revert.

Proof of Concept

Users can call the claim() to claim their tokens depending on the timespan they were deposited for.

File: SecondSwap_StepVesting.sol

    function claim() external {
        (uint256 claimableAmount, uint256 claimableSteps) = claimable(msg.sender);
        require(claimableAmount > 0, "SS_StepVesting: nothing to claim");

        Vesting storage vesting = _vestings[msg.sender];
        vesting.stepsClaimed += claimableSteps;
        vesting.amountClaimed += claimableAmount;

        token.safeTransfer(msg.sender, claimableAmount); //  3.6. DOS caused by the use of transfer and transferFrom functions
        emit Claimed(msg.sender, claimableAmount);
    }

transferVesting() creates a new vesting for the new owner making necessary calculations to ensure that the previous owner does not experience any loss.

File: SecondSwap_StepVesting.sol

    function transferVesting(address _grantor, address _beneficiary, uint256 _amount) external {
        require(
            msg.sender == tokenIssuer || msg.sender == manager || msg.sender == vestingDeployer,
            "SS_StepVesting: unauthorized"
        );
        require(_beneficiary != address(0), "SS_StepVesting: beneficiary is zero");
        require(_amount > 0, "SS_StepVesting: amount is zero");
        Vesting storage grantorVesting = _vestings[_grantor];
        require(
            grantorVesting.totalAmount - grantorVesting.amountClaimed >= _amount,
            "SS_StepVesting: insufficient balance"
        ); // 3.8. Claimed amount not checked in transferVesting function

        grantorVesting.totalAmount -= _amount;
        grantorVesting.releaseRate = grantorVesting.totalAmount / numOfSteps;

        _createVesting(_beneficiary, _amount, grantorVesting.stepsClaimed, true);

        emit VestingTransferred(_grantor, _beneficiary, _amount);
    }

Scenario

  • Bob is the owner of a vesting & has a totalAmount of 100 tokens.
  • Bob been the holder of the vesting for quite sometime & can claim the some amount of tokens. He hasn’t claimed any of its tokens so amountClaimed is 0 at this point.
  • Now, suppose the tokenIssuer decides to transfers Bob’s entire vesting of 100 tokens to Alice’s vesting address so the tokenIssuer calls transferVesting().
  • Bob sees this call & frontruns it by calling the claim().
  • Say that a total of 70 tokens has now been transferred to Bob which sets amountClaimed for Bob’s vesting to be 70.
  • When transferVesting() is executed, it reverts because of the below check.
File: SecondSwap_StepVesting.sol

    function transferVesting(address _grantor, address _beneficiary, uint256 _amount) external {
       ...
        Vesting storage grantorVesting = _vestings[_grantor];
>       require(
>           grantorVesting.totalAmount - grantorVesting.amountClaimed >= _amount,
>           "SS_StepVesting: insufficient balance"
        ); // 3.8. Claimed amount not checked in transferVesting function
        ...

In the above situation, if Bob’s entire amount is claimable & he frontruns the call to transferVesting(), no transfer of vesting is possible to another address.

Recommended mitigation steps

A way would be to pause claiming of tokens when transferring to avoid this issue & unpause later.

calvinx (SecondSwap) commented:

This is a low likelihood scenario.

Koolex (judge) commented:

Due to the low likelihood, this could be low/med.

Clarify in one or two statements what is the impact, and why would you think it is high?

Otherwise, this will be set as low.

ABAIKUNANBAEV (warden) commented:

@Koolex I don’t believe that it’s a high - I think it’s a med as it was stated by the protocol that vesting grantor has to be able to freely transfer the vestings - in this scenario, he can clearly face DoS

And it’s a very high probability as users can use the strategy of not claiming the funds to then DoS the grantor

Koolex (judge) commented:

Taking into account the input above, this is a valid Medium


The original report as published on Code4rena, by Shubham. 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.

What is known

A medium-severity doS bug in SecondSwap. Code4rena made it public on 18 February 2025. Found in the 2024-12-secondswap audit contest (finding M-16), also found by 1 other warden.

About DoS

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

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 by Shubham

View all

1 more disclosed report, best first.

More from SecondSwap

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.