createPoolD650E2D0 will not work due to mismatch in solidity and stylus function definitions
The Solidity function createPoolD650E2D0 has a different signature from the Stylus function it calls, so direct calls to create a pool always fail. An attacker cannot exploit this, but the intended pool creation functionality is broken.
SeaWaterAMM.sol holds the createPoolD650E2D0 which allows the admin to initialize a new pool. It calls the create_pool_D650_E2_D0 function in the stylus.
As can be seen from the create_pool_D650_E2_D0 function, it takes in the token address, sqrtPriceX96 and fee.
But createPoolD650E2D0’s definition takens in more, token address, sqrtPriceX96, fee, tick spacing and maxLiquidityPerTick, causing a mismatch between the function definitions of the Solidity and Stylus contracts.
The Warden has correctly identified that the function definitions of the Solidity and Stylus contracts differ, resulting in the relevant functionality of the system being inaccessible.
In line with the previous audit’s rulings, I believe a high-risk rating is appropriate for this submission as pool creations are rendered inaccessible via any other functions in contrast to the original audit’s submission which permitted circumvention of this error.
I believe some key pieces of information are missing to provide an accurate severity assessment, which I will address in this comment.
It is true that createPoolD650E2D0 will not work if directly called, as it has the wrong ABI, and this finding is technically valid. However, there is a fallback function that allows the creation of new pools by using the correct ABI.
The correct ABI, like this issue points, is the following:
createPoolD650E2D0(address,uint256,uint32)
So the third byte is 0x80:
function testAbi() public pure returns (bytes1) {
return abi.encodeWithSignature("createPoolD650E2D0(address,uint256,uint32)", address(0), 0, 0)[2];
}
decoded output { “0”: “bytes1: 0x80” }
If we look at the fallback function, the execution will fall under the executor fallback:
fallback() external {
// swaps
if (uint8(msg.data[2]) == EXECUTOR_SWAP_DISPATCH)
directDelegate(_getExecutorSwap());
// update positions
else if (uint8(msg.data[2]) == EXECUTOR_UPDATE_POSITION_DISPATCH)
directDelegate(_getExecutorUpdatePosition());
// positions
else if (uint8(msg.data[2]) == EXECUTOR_POSITION_DISPATCH)
directDelegate(_getExecutorPosition());
// admin
else if (uint8(msg.data[2]) == EXECUTOR_ADMIN_DISPATCH)
directDelegate(_getExecutorAdmin());
// swap permit 2
else if (uint8(msg.data[2]) == EXECUTOR_SWAP_PERMIT2_A_DISPATCH)
directDelegate(_getExecutorSwapPermit2A());
// quotes
else if (uint8(msg.data[2]) == EXECUTOR_QUOTES_DISPATCH) directDelegate(_getExecutorQuote());
else if (uint8(msg.data[2]) == EXECUTOR_ADJUST_POSITION_DISPATCH) directDelegate(_getExecutorAdjustPosition());
else if (uint8(msg.data[2]) == EXECUTOR_SWAP_PERMIT2_B_DISPATCH) directDelegate(_getExecutorSwapPermit2B());
-> else directDelegate(_getExecutorFallback());
}
Moreover, creating a pool is permissionless and intended by the Sponsor, it doesn’t have to be called by the executor admin; the executor fallback would be able to create new pools.
Therefore, there is no loss of funds, and the functionality of the protocol is not impacted in this way; I don’t see how a High risk can be justified. I believe this issue falls under the QA umbrella, as a function does not work according to specifications.
@DadeKuma - This submission’s assessment is in line with the previous audit and the presence of a fallback mechanism is not sufficient to justify the finding’s invalidation. Otherwise, any inaccessible functionality of the system could be argued as being present in the fallback function and all findings pertaining to it would have to be invalidated in the previous audit as well.
Given that wardens were aware of the judgment style of this particular submission type, I do not believe that downgrading it in the follow-up round is a fair approach.
The original report as published on Code4rena, by ZanyBonzy. 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.
Generating the AI write-up for this report.
This usually takes about 40 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
The Solidity function createPoolD650E2D0 declares five parameters while the Stylus function create_pool_D650_E2_D0 accepts only three, causing an ABI mismatch.
What the attacker needed
None
The fix
The unneeded parameters (tickSpacing and maxLiquidityPerTick) should be removed from the Solidity function definition to match the Stylus function.
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.
Generating the AI write-up for this report.
This usually takes about 40 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
This is a smart contract bug where two parts of the system expect different inputs for the same action. The Solidity part asks for five pieces of information, but the Stylus part only accepts three, so the call never works. As a result, users cannot create a new pool through this function.
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.