Skip to content
Business logic Audit finding Intermediate

User funds lost because they can’t withdraw() their funds before epoch startTime and they are stuck in positions that become unprofitable even when epoch is not started

The Vault contract only lets users withdraw after an epoch ends, with no way to withdraw during the period between depositing and the epoch start. A user whose position becomes unfavourable before the epoch begins is therefore stuck with no way to exit.

unforgiven Follow

Originally disclosed on Code4rena

Submitted by unforgiven, also found by carrotsmuggler and cccz

Users deposit their funds in Vault when epoch is not started but as other users deposit funds too or price of pegged token changes, users get different risk to reward. And they may want to withdraw their funds before epoch start time to get out of bad position, but there is no logic in code to give them ability to withdraw their funds before epoch start time.

Proof of Concept

Withdraw() function in Vault only allows users to withdraw after epoch ends and there is no logic in the contract to allow users to withdraw their funds before epoch start time.

After users deposit their funds, the risk to reward ratio of their investment changes as other users deposit funds in one of the Vaults and user may wants to withdraw their funds if they saw that position is bad for them or maybe the price of that token has been changed dramatically before epoch startTime and users wants to withdraw. But, there is no functionality that gives users the ability to withdraw their funds before epoch start time and users lose control of their funds after depositing and before epoch start time. As epoch is not started yet, users should be able to withdraw their funds but there is no such functionality in the code.

Tools Used

VIM

Recommended Mitigation Steps

Add some logic to give users the ability to withdraw funds before epoch start time.

MiguelBits (Y2K Finance) disputed and commented:

Working as intended.


The original report as published on Code4rena, by unforgiven. 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 withdrawal function was only designed for the post-epoch path, so no code path exists for withdrawing during the pre-epoch deposit window.

Impact

Users lose control of their funds between deposit and epoch start and may be stuck in positions that become unprofitable; the project disputed this, saying it works as intended.

What the attacker needed

User deposits before epoch starts; position becomes unfavourable

The fix

The report recommends adding logic that lets users withdraw funds before the epoch start time, though the project disputed the finding.

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 vault is a contract that holds people's money. Users put money in before a round (an epoch) starts, but the only way to take it out is after the round finishes. If the deal turns bad before the round even begins, they cannot get their money 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 unforgiven

View all

50 more disclosed reports, best first.

More from Y2k Finance contest

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.