Skip to content
Smart contracts Audit finding Intermediate

withdrawAVAX() function has call to sender without reentrancy protection

The withdrawAVAX() function in LaunchEvent.sol makes an external call to the caller without a reentrancy guard, allowing the caller to reenter this and other functions. An attacker could exploit this to reenter and potentially drain funds or manipulate state.

jayjonah8 Follow

Originally disclosed on Code4rena

Submitted by jayjonah8

In LauchEvent.sol the withdrawAVAX() function makes an external call to the msg.sender by way of _safeTransferAVAX. This allows the caller to reenter this and other functions in this and other protocol files. To prevent reentrancy and cross function reentrancy there should be reentrancy guard modifiers placed on the withdrawAVAX() function and any other function that makes external calls to the caller.

Proof of Concept

https://github.com/code-423n4/2022-01-trader-joe/blob/main/contracts/LaunchEvent.sol#L368

https://github.com/code-423n4/2022-01-trader-joe/blob/main/contracts/LaunchEvent.sol#L370

Recommended Mitigation Steps

Add reentrancy guard modifier to withdrawAVAX() function.

cryptofish7 (Trader Joe) confirmed and commented:

Resolved using CEI: https://github.com/traderjoe-xyz/rocket-joe/commit/dbd19cc400abb5863edfc0443dd408ba5ae3e99a


The original report as published on Code4rena, by jayjonah8. 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 withdrawAVAX() function performs an external call to msg.sender without a reentrancy guard modifier.

What the attacker needed

Ability to call withdrawAVAX()

The fix

The issue was resolved by applying the checks-effects-interactions pattern.

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 reentrancy attack happens when a contract calls another contract (or a user) before it has finished updating its own records. The called code can then call back into the original function and repeat actions, like withdrawing funds multiple times. Here, the withdrawAVAX function sends AVAX to the caller without a guard, so the caller 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 jayjonah8

View all

18 more disclosed reports, best first.

More from Trader Joe 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.