Skip to content
Business logic Audit finding Intermediate

Missing option to remove tokens from the isTokenSupport mapping can result in huge financial loss for users and the protocol

The marketplace contract lacks a function to remove a token from the whitelist of supported payment currencies. If a whitelisted stablecoin depegs, users can still list and sell vestings for that worthless token, causing financial loss to sellers and the protocol.

BenRai Follow with 0xAkira, 0xrex and 5 others

Originally disclosed on Code4rena

Submitted by BenRai, also found by 0xAkira, 0xrex, 0xStalin, BajagaSec, Bryan_Conquer, Taiger, and zanderbyte

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

Because there is no option for the admin to remove a token from the isTokenSupport mapping, a depeg of a whitelisted token can lead to significant financial loss for users and the protocol.

Proof of Concept

When selling a vesting on the marketplace, users need to specify the currency the buyer should pay for the sold tokens. To ensure the safety of the users and the safety of the protocol’s revenue, only currencies whitelisted in the isTokenSupport mapping can be used and according to the protocol only stable coins will be whitelisted. For a token to be whitelisted the function addCoin needs to be called by the admin.

The issue arises from the fact that there is no way to remove a coin from the whitelist once it is on it. This poses a significant risk for the users and the revenue of the protocol in case a whitelisted stable coin loses his peg and becomes worthless. Even though the coin becomes worthless:

  • unsuspecting users can still list their vestings using the worthless currency, practically giving away their tokens for free
  • all listings using this currency can still be bought, resulting in significant loss for the seller
  • the fees for the protocol collected for listings using the depegged currency will also be worthless

This results in significant financial loss for users as well as the protocol.

Recommended Mitigation Steps

Add an option for the admin to remove currencies from the whitelist. This way, no new listings can be created with a depegged currency. To protect the vestings already listed with the bad currency, make sure to check if the currency used for a listing is still on the whitelist before executing a sale. This way, sellers of the impacted listings are protected from selling their vestings for worthless currency and can delist their listings once they become aware of the depeg.

Koolex (judge) commented:

Validator’s comment:

The supported tokens are under protocol team’s review, we can expect that most widely used token such as ETH/USDC/USDC to be included as currency token. Though it’s a good idea to have a quit design, QA is proper to this issue.

My view after further evaluation: Since all ERC20 tokens are supported, depegged currency risk is still there, even for USDC which actually dropped under 1$ about a year ago. Therefore, at this point, I believe this can be Medium.

calvinx (SecondSwap) commented:

In our initial design, we will only use liquid stables, i.e. USDT and USDC. In a depeg scenario, we can freeze listing and recommend sellers to remove their listings. We will include a fix.


The original report as published on Code4rena, by BenRai. 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 provides a function to add supported tokens but no function to remove them, so a depegged token remains accepted indefinitely.

Impact

If a whitelisted stablecoin depegs, sellers can still list and sell vestings for that worthless token, causing financial loss to users and the protocol; the protocol team says they can freeze listings and will include a fix.

What the attacker needed

A whitelisted stablecoin depegs; admin cannot remove the token

The fix

Add an admin function to remove currencies from the whitelist and check that a listing's currency is still whitelisted before executing a sale.

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 sell locked-up tokens (vestings) and choose which stablecoin to receive as payment. Only approved stablecoins are allowed, but once a coin is approved, the admin cannot remove it. If that stablecoin loses its value (depegs), sellers might still accept it and get almost nothing, and the protocol earns worthless fees.

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 BenRai

View all

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