Skip to content
Business logic Audit finding Intermediate

Users are incentivized to not withdraw immediately after the market is closed

Withdrawal batches pay all users in the batch at the same rate, so when a market closes with an outstanding expiry batch, new withdrawers join the old batch and are dragged down to its lower rate. This incentivises users to keep funds in the contract until the expiry timestamp to get a higher rate, rather than withdrawing immediately.

deadrxsezzz Follow

Originally disclosed on Code4rena

Submitted by deadrxsezzz

Within a withdraw batch, all users within said batch are paid equally - at the same rate, despite what exactly was the rate when each individual one created their withdraw.

While this usually is not a problem as it is a way to reward users who queue the withdrawal and start the expiry cooldown, it creates a problematic situation when the market is closed with an outstanding expiry batch.

The problem is that up until the expiry timestamp comes, all new withdraw requests are added to this old batch where the rate of the previous requests drags the overall withdraw rate down.

Consider the following scenario:

  1. A withdraw batch is created and its expiry time is 1 year.
  2. 6 months in, the withdraw batch has half of the markets value in it and the market is closed. The current rate is 1.12 and the batch is currently filled at 1.06
  3. Now users have two choices - to either withdraw their funds now at ~1.06 rate or wait 6 months to be able to withdraw their funds at 1.12 rate.

This creates a very unpleasant situation as the users have an incentive to hold their funds within the contract, despite not providing any value.

Looked from slightly different POV, these early withdraw requesters force everyone else to lock their funds for additional 6 months, for the APY they should’ve usually received for just holding up until now.

Recommended Mitigation Steps

After closing a market and filling the current expiry, delete it from pendingWithdrawalExpiry. Introduce a closedExpiry variable so you later make sure a future expiry is not made at that same timestamp to avoid collision.

d1ll0n (Wildcat) confirmed and commented:

Thanks for this, good find! Will adopt the proposed solution and see if it fixes H-01.

laurenceday (Wildcat) commented:

Fixed with wildcat-finance/v2-protocol@b25e528.


The original report as published on Code4rena, by deadrxsezzz. 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 protocol keeps a closed market's outstanding expiry batch active, so new withdrawal requests are added to it and inherit its older, lower rate.

Impact

Users are incentivised to keep funds locked in the contract without providing value, and early withdraw requesters can force others to wait an extra six months for the rate they would normally have received.

What the attacker needed

A market with an outstanding expiry batch; the market is closed before the batch expires

The fix

The project adopted the proposed fix of removing a filled expiry from pendingWithdrawalExpiry after a market closes and tracking a closedExpiry variable to avoid timestamp collisions, and it was fixed in a commit.

How it was found

  1. A withdraw batch is created with an expiry time of one year.
  2. Six months later the batch holds half the market's value and the market is closed.
  3. The current rate is 1.12 while the batch is filled at 1.06.
  4. Users can withdraw now at about 1.06 or wait six months to withdraw at 1.12.

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 withdrawal batch is a queue where everyone who joins gets paid at one shared rate. If the market closes while an old batch is still waiting, anyone who joins that batch is paid at the old, lower rate. So people are better off leaving their money in until the batch expires, even though they are not helping the market.

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 deadrxsezzz

View all

11 more disclosed reports, best first.

More from The Wildcat Protocol

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.