Skip to content
Business logic Audit finding Intermediate

MarketPlace Change In Vesting Manager, Leads To Loss Of Previous MarketPlace Listing

When the admin changes the marketplace address in the VestingManager, the old marketplace can no longer call the VestingManager because of the onlyMarketplace check. Listings made on the previous marketplace become stuck, so users cannot unlist or purchase them.

franfran20 Follow with 0xLasadie, BenRai and 3 others

Originally disclosed on Code4rena

Submitted by franfran20, also found by 0xLasadie, BenRai, BenRai, EPSec, and franfran20

https://github.com/code-423n4/2024-12-secondswap/blob/214849c3517eb26b31fe194bceae65cb0f52d2c0/contracts/SecondSwap_VestingManager.sol#L204

https://github.com/code-423n4/2024-12-secondswap/blob/214849c3517eb26b31fe194bceae65cb0f52d2c0/contracts/SecondSwap_VestingManager.sol#L121

https://github.com/code-423n4/2024-12-secondswap/blob/214849c3517eb26b31fe194bceae65cb0f52d2c0/contracts/SecondSwap_VestingManager.sol#L149

https://github.com/code-423n4/2024-12-secondswap/blob/214849c3517eb26b31fe194bceae65cb0f52d2c0/contracts/SecondSwap_VestingManager.sol#L161

When interacting with the MarketPlace contract and vesting listings, the MarketPlace contract calls the VestingManager contract (using the address gotten from the MarketplaceSetting contract) which calls the StepVesting contract itself to transfer vestings from one address to another.

The VestingManager contract contains the setMarketplace function which is in place in case the MarketPlace contract needs to be changed and redeployed instead of an upgrade (upgrades to the MarketPlace contract occur through the proxy admin, so this function is to change the proxy entirely). When a new MarketPlace contract is set, all previous listings in the marketplace remain stuck, unlistable or inaccessible by the user who listed them, leading to loss of vested assets, simply because the VestingManager is no longer connected to that instance of the marketplace.

Proof of Concept

Let’s take a user who has a total amount of 1000 Token F vested. The user decides to list 200 of these tokens on the marketplace. After this period that the listing is active, the VestingManager contract updates the MarketPlace contract(not an upgrade, a complete change of the proxy).

The function that changes the marketplace address in the VestingManager

   function setMarketplace(address _marketplace) external onlyAdmin {
        marketplace = _marketplace;
    }

The issue lies in the fact that the VestingManager no longer points to the previous marketplace were the listing was made. So those listings that existed in the former marketplace can no longer be unlisted or purchased by another user. Simply because the functions listVesting and unlistVesting in the MarketPlace contract rely on calling the VestingManager contract, which no longer recognizes the old marketplace, only the new one.

There is a freeze function that should supposedly stop all actions on the marketplace to give enough time for users to unlist their listed vestings but when the marketplace is frozen, unlisting and purchasing listings are also frozen. See below:

    function unlistVesting(address _vestingPlan, uint256 _listingId) external isFreeze { // <== contains the isFreeze modfiier
        // .... some code here .....
    }

    function spotPurchase(
        address _vestingPlan,
        uint256 _listingId,
        uint256 _amount,
        address _referral
    ) external isFreeze  { // <= contains the isFreeze modifier
        // .... some code here .....
    }

So when the old marketplace with users listings tries to call the VestingManager contract, it reverts simply because the marketplace recognized in the Vesting manager is not the same as the Old marketplace that contained all previous listings.

    // the onlyMarketplace modifier recognizes the new marketplace and not the old marketplace and results in a revert
    function unlistVesting(address seller, address plan, uint256 amount) external onlyMarketplace {}
    function completePurchase(address buyer, address vesting, uint256 amount) external onlyMarketplace {}

// The modifier check
    modifier onlyMarketplace() {
        require(msg.sender == marketplace, "SS_VestingManager: caller is not marketplace");
        _;
    }

This leads to the vestings that were in the previous MarketPlace becoming inaccessible, unlistable or unpurchaseable.

Major impact would be that all the vestings that were listed in the old marketplace would no longer be accessible because the vesting manager is pointing to a new marketplace contract, leading to loss of vestings listed before the change happened due to them being inaccessible via unlisting or purchasing.

Recommended mitigation steps

Provide a way to allow after a change in the marketplace contract, the user to be able to remove their vested listings and transfer it back to their address from the previous marketplace.

TechticalRAM (SecondSwap) acknowledged


The original report as published on Code4rena, by franfran20. 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 VestingManager stores a single marketplace address and rejects calls from any other, so changing it orphans listings on the previous marketplace.

Impact

Listings on the previous marketplace become inaccessible, unlistable and unpurchaseable, which could lead to loss of the vested assets listed there.

What the attacker needed

Admin changes the marketplace address; user has an active listing on the old marketplace

The fix

The report recommends allowing users to remove their vested listings and transfer them back after a marketplace change.

How it was found

  1. A user lists part of their vested tokens on the marketplace.
  2. The admin calls setMarketplace to point the VestingManager at a new marketplace.
  3. The old marketplace calls the VestingManager to unlist or complete a purchase.
  4. The onlyMarketplace check reverts because the caller is no longer the stored marketplace.

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 marketplace contract lets people list tokens that are still vesting (being released over time). A separate manager contract moves those tokens around, and it only trusts one marketplace address at a time. If the admin swaps that address, the old marketplace is no longer trusted, so its listings are frozen and users cannot get their tokens back.

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 franfran20

View all

2 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.

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.