Skip to content
Access control Audit finding Intermediate

Creator of one vesting plan can affect vesting plans created by other users.

The vesting deployer contract stored token ownership in a mapping keyed by owner address rather than token address, allowing a token to have multiple owners. A creator of one vesting plan could then influence or create vesting plans for the same token, potentially causing loss of funds from the actual creator.

sl1 Follow with 0xDemon, 0xGondar and 19 others

Originally disclosed on Code4rena

Submitted by sl1, also found by 0xDemon, 0xGondar, 0xKann, ABAIKUNANBAEV, Abhan, boredpukar, ctmotox2, ctmotox2, curly, dhank, EPSec, fyamf, fyamf, m4k2, peanuts, pulse, rspadi, Shinobi, spuriousdragon, yuza101, and zanderbyte

https://github.com/code-423n4/2024-12-secondswap/blob/214849c3517eb26b31fe194bceae65cb0f52d2c0/contracts/SecondSwap_VestingDeployer.sol#L141-L144

https://github.com/code-423n4/2024-12-secondswap/blob/214849c3517eb26b31fe194bceae65cb0f52d2c0/contracts/SecondSwap_VestingDeployer.sol#L176-L183

https://github.com/code-423n4/2024-12-secondswap/blob/214849c3517eb26b31fe194bceae65cb0f52d2c0/contracts/SecondSwap_VestingDeployer.sol#L218-L231

https://github.com/code-423n4/2024-12-secondswap/blob/214849c3517eb26b31fe194bceae65cb0f52d2c0/contracts/SecondSwap_VestingDeployer.sol#L193-L206

Vesting plans are created by token issuers in the VestingDeployer contract. When a vesting plan is created, a new StepVesting contract is deployed.

SecondSwap_VestingDeployer.sol#L119-L129

address newVesting = address(
    new SecondSwap_StepVesting(
        msg.sender,
        manager,
        IERC20(tokenAddress),
        startTime,
        endTime,
        steps,
        address(this)
    )
);

This contract address will be used by token issuers to manage their vesting plans. However, currently it’s possible that a creator of one vesting plan can affect vesting plans created by other users.

Token issuers are set by the admin in the setTokenOwner() function.

SecondSwap_VestingDeployer.sol#L141-L144

function setTokenOwner(address token, address _owner) external onlyAdmin {
    require(
        _tokenOwner[_owner] == address(0),
        "SS_VestingDeployer: Existing token have owner"
    );
    _tokenOwner[_owner] = token;
}

As can be seen, it’s possible for a token to have multiple owners, as the mapping used is owner => token instead of token => owner. Now if one token has multiple owners and there are 2 vesting plans, creator of vesting plan A can influence vesting plan B and vice versa.

createVesting() and createVestings() functions check that token that is linked to the msg.sender is the same as the token of the vesting plan, which in this case will be true regardless of the fact that msg.sender is not the creator of said vesting plan.

SecondSwap_VestingDeployer.sol#L176-L183

require(
    _tokenOwner[msg.sender] ==
        address(SecondSwap_StepVesting(_stepVesting).token()),
    "SS_VestingDeployer: caller is not the token owner"
);

But when _createVesting() function of the StepVesting contract will be invoked, it will transfer funds not from the msg.sender but from the actual creator of the vesting plan.

SecondSwap_StepVesting.sol#L306-L308

if (!_isInternal) {
    token.safeTransferFrom(tokenIssuer, address(this), _totalAmount);
}

transferVesting() function is also vulnerable to that issue because it uses the same check as createVesting().

SecondSwap_VestingDeployer.sol#L218-L228

function transferVesting(
    address _grantor,
    address _beneficiary,
    uint256 _amount,
    address _stepVesting,
    string memory _transactionId
) external {
    require(
        _tokenOwner[msg.sender] ==
            address(SecondSwap_StepVesting(_stepVesting).token()),
        "SS_VestingDeployer: caller is not the token owner"
    );

Impact

Creator of one vesting plan can influence vesting plans created by other users.

Recommended Mitigation

Store the address of the vesting plan’s creator in a mapping(address vestingPlan => address creator) and check if the msg.sender is the actual creator of the vesting plan.

Koolex (judge) commented:

But when _createVesting() function of the StepVesting contract will be invoked, it will transfer funds not from the msg.sender but from the actual creator of the vesting plan.

I believe this can be Medium since the impact is high as functionality is broken (not working as intended), and a possible loss of funds + a low likelihood.


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

The contract used a mapping from owner to token instead of token to owner, allowing multiple owners per token and missing a check that the caller is the actual creator of the specific vesting plan.

Impact

A creator of one vesting plan could influence vesting plans created by other users, potentially causing loss of funds and breaking intended functionality.

What the attacker needed

Token has multiple owners; attacker is one of the owners

The fix

The contract should store the creator of each vesting plan in a mapping and check that the caller is the actual creator before allowing actions.

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.

In a smart contract, a mapping is like a dictionary that links one value to another. Here, the contract stored which token each owner controlled, but it should have stored which owner controlled each token. Because of this, two different people could be recorded as owners of the same token, and one could act on the other's vesting plan.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by sl1

View all

4 more disclosed reports, 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.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.