Skip to content
Access control Audit finding Intermediate

Malicious owner can drain the market at any time using SafetyWithdraw

The SafetyWithdraw contract allows the market owner to withdraw any ERC20 token, including the tracerQuoteToken, at any time. A malicious owner could drain all deposited quote tokens, causing users to lose their deposits.

0xRajeev Follow

Originally disclosed on Code4rena

Submitted by 0xRajeev, also found by pauliax and gpersoon

The withdrawERC20Token() in SafetyWithdraw inherited in TracerPerpetualSwaps is presumably a guarded launch emergency withdrawal mechanism. However, given the trust model where the market creator/owner is potentially untrusted/malicious, this is a dangerous approach to emergency withdrawal in the context of guarded launch.

Alternatively, if this is meant for the owner to withdraw “external” ERC20 tokens mistakenly deposited to the Tracer market, then the function should exclude tracerQuoteToken from being the tokenAddress that can be used as a parameter to withdrawERC20Token().

The impact of this is that, if a malicious owner of a market withdraws/rugs all tracerQuoteTokens deposited at any time after market launch, all users lose deposits and the protocol takes a reputational hit and has to refund the users from treasury.

Therefor, it is recommended that, for a guarded launch circuit breaker, design a pause/unpause feature where deposits are paused (in emergency situations) but withdrawals are allowed by the depositors themselves instead of the owner. Alternatively, if this is meant to be for removing external ERC20 tokens accidentally deposited to market, exclude the tracerQuoteToken from being given as the tokenAddress.

raymogg (Tracer) confirmed but suggested a severity of 2:

The only reason for the dispute on severity is that as part of the security model, the owner can manipulate the market in other ways (such as changing the oracle being used), so this trust assumption over the owner already exists. For this reason the team thinks this issue is closer to a medium

This however is a good issue as it is not the greatest circuit breaking mechanism, and as noted in #7 can reflect badly on the project without the exploit being used. The mechanism is being removed and replaced with more structured circuit breaker.

cemozerr (Judge) commented:

Marking this as high risk, as regardless of the owner manipulating in other ways, the threat persists.

The original report as published on Code4rena, by 0xRajeev. 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 withdrawERC20Token function does not exclude the tracerQuoteToken from being withdrawn by the owner, allowing the owner to drain user deposits.

Impact

A malicious owner could withdraw all tracerQuoteTokens, causing users to lose deposits and the protocol to suffer reputational damage and need to refund from treasury.

What the attacker needed

Malicious market owner

The fix

The mechanism is being removed and replaced with a more structured circuit breaker that pauses deposits but allows depositors to withdraw, and excludes the quote token from owner withdrawals.

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 the person who created a market take out any token, including the one users deposit. If that person is malicious, they can take all the deposited tokens and users lose their money.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by 0xRajeev

View all

61 more disclosed reports, best first.

More from Tracer contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.