Skip to content
Business logic Audit finding Intermediate

buyFee And sellFee Should Be Known Before Purchase

The marketplace lets the buy and sell fees for a vesting plan be changed after a listing is created, so the fees a seller will pay are not fixed at listing time. A seller can therefore receive less revenue than expected if the seller fee is raised later.

EPSec Follow with 0xhuh2005, BenRai and 4 others

Originally disclosed on Code4rena

Submitted by EPSec, also found by 0xhuh2005, BenRai, KupiaSec, rouhsamad, sl1, and typicalHuman

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

The platform allows the buyFee and sellFee parameters for a vesting plan to be modified after a listing is created. This creates a significant issue in terms of transparency and predictability for users engaging in transactions.

Impact on Users

  1. Uncertainty for Buyers and Sellers:

    Both buyers and sellers cannot reliably determine the exact fees associated with a transaction until the spotPurchase function is executed. This lack of transparency diminishes user confidence in the platform.

  2. Financial Discrepancies for Sellers:

    Sellers may receive less revenue than anticipated if the seller fee (sellFee) is increased after the listing is created. This directly impacts their earnings and could lead to dissatisfaction or distrust in the platform’s fee structure.

Proof of Concept

Let’s have the following scenario:

  1. User A creates listing, currently the fees for this vesting plan are 1000 and 1000.
  2. After some period these fees are changed to 5000 for the seller fee and 1000 for buyer fee.
  3. User A will receive less money, because the fee is bigger.

Recommended mitigation steps

Consider two additional parameters to be added for the listing:

(uint256 bfee, uint256 sfee) = _getFees(_vestingPlan);
listings[_vestingPlan][listingId] = Listing({
		seller: msg.sender,
		total: _amount,
		balance: _amount,
		pricePerUnit: _price,
		listingType: _listingType,
		discountType: _discountType,
		discountPct: _discountPct,
		listTime: block.timestamp,
		whitelist: whitelistAddress,
		currency: _currency,
		minPurchaseAmt: _minPurchaseAmt,
		status: Status.LIST,
		vestingPlan: _vestingPlan,
+       buyerFee: bfee,
+       sellerFee: sfee
	});
	emit Listed(_vestingPlan, listingId);
}

Also make the changes to the Listing struct and spotPurchase to use the correct fees.

TechticalRAM (SecondSwap) acknowledged

calvinx (SecondSwap) commented:

We will show this in UI as fees can be negotiated and set later

Koolex (judge) commented:

I think the issue here is, no protection for the user in case fee changed.


The original report as published on Code4rena, by EPSec. 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 listing does not store the fee values at creation time, so the purchase reads whatever fee the vesting plan currently has.

Impact

Sellers could receive less revenue than anticipated, and neither buyers nor sellers can know the exact fees until the purchase executes.

What the attacker needed

A listing on the marketplace; fees changed after listing

The fix

The listing should record the buyer and seller fees at creation time and the purchase should use those stored values.

How it was found

  1. A user creates a listing while the vesting plan fees are set to certain values.
  2. After some time the seller fee is increased.
  3. The user receives less money because the fee is now larger.

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 seller lists tokens for sale and expects a certain amount of money after the platform takes its cut. The problem is that the platform's cut can be changed after the listing is made, so the seller may end up with less than they planned. Buyers and sellers only learn the real fee when the purchase actually happens.

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 EPSec

View all

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