Pair creation can be denied
Submitted by cmichel, also found by harleythedog, UncleGrandpa925, and WatchPug
The LaunchEvent.createPair requires that no previous pool was created for the WAVAX <> _token pair.
function createPair() external isStopped(false) atPhase(Phase.PhaseThree) {
(address wavaxAddress, address tokenAddress) = (
address(WAVAX),
address(token)
);
// @audit grief: anyone can create pair
require(
factory.getPair(wavaxAddress, tokenAddress) == address(0),
"LaunchEvent: pair already created"
);
// ...
}
A griefer can create a pool for the WAVAX <> _token pair by calling JoeFactory.createPair(WAVAX, _token) while the launch event phase 1 or 2 is running. No liquidity can then be provided and an emergency state must be triggered for users and the issuer to be able to withdraw again.
Recommendation
It must be assumed that the pool is already created and even initialized as pool creation and liquidity provisioning is permissionless. Special attention must be paid if the pool is already initialized with liquidity at a different price than the launch event price.
It would be enough to have a standard min. LP return “slippage” check (using parameter values for amountAMin/amountBMin instead of the hardcoded ones in router.addLiquidity) in LaunchEvent.createPair(). The function must then be callable with special privileges only, for example, by the issuer. Alternatively, the slippage check can be hardcoded as a percentage of the raised amounts (amountADesired = 0.95 * wavaxReserve, amountBDesired = 0.95 * tokenAllocated).
This will prevent attacks that try to provide LP at a bad pool price as the transaction will revert when receiving less than the slippage parameter. If the pool is already initialized, it should just get arbitraged to the auction token price and liquidity can then be provided at the expected rate again.
cryptofish7 (Trader Joe) confirmed, but disagreed with High severity and commented:
Fix: https://github.com/traderjoe-xyz/rocket-joe/pull/81
Should be 2 (Medium).
LSDan (judge) decreased severity to Medium and commented:
This issue would not put assets at risk. but would impact the availability of the protocol for certain pairs.
2 — Med (M): vulns have a risk of 2 and are considered “Medium” severity when assets are not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity business logic bug in Trader Joe contest. Code4rena made it public on 7 March 2022. Found in the 2022-01-trader-joe audit contest (finding M-12).
About Business logic
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
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.