Skip to content
Smart contracts Audit finding Intermediate

Add reentrancy protections on function executeTrade

The executeTrade function in the Trader contract can be reentered because it calls an external contract controlled by the user. An attacker could exploit this to reenter critical functions, though the team notes whitelisting may limit the impact.

shw Follow

Originally disclosed on Code4rena

Submitted by shw, also found by 0xRajeev

As written in the to-do comments, reentrancy could happen in the executeTrade function of Trader since the makeOrder.market can be a user-controlled external contract. See L121-L126 in Trader.sol.

Recommend adding a reentrancy guard (e.g., the implementation from OpenZeppelin) to prevent the users from reentering critical functions.

raymogg (Tracer) disputed:

Disputing just as while this is important, its quite explicitly stated in the todo comment and as such is already known by the team as a potential issue.

Realistically shouldn’t be too much of a problem with whitelisting of the trader.

cemozerr (Judge) commented:

Marking this as medium risk as, regardless of being noted by the team, still poses a security threat.

OsmanBran (Tracer) commented:

Duplicate of #72

The original report as published on Code4rena, by shw. 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

Impact

An attacker could reenter critical functions, though the team believes whitelisting of the trader would realistically limit the problem.

What the attacker needed

Whitelisted trader (per team comment)

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.

Reentrancy is when a contract calls another contract, and that other contract calls back into the first one before the first call finishes. This can let an attacker repeat actions or manipulate state. Here, the executeTrade function calls an external contract that the user controls, so the user could reenter and cause problems.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by shw

View all

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

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.