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