Initialization Deadlock in KatanaV3Pool Due to Conflicting Constructor and initializeImmutables Logic #44
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-26
🤖_04_group
AI based duplicate group recommendation
sufficient quality report
This report is of sufficient quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/ronin-chain/katana-v3-contracts/blob/03c80179e04f40d96f06c451ea494bb18f2a58fc/src/core/KatanaV3Pool.sol#L111
https://github.com/ronin-chain/katana-v3-contracts/blob/03c80179e04f40d96f06c451ea494bb18f2a58fc/src/core/KatanaV3Pool.sol#L117
Vulnerability details
Summary
The KatanaV3Pool contract has an initialization deadlock where the constructor sets
factory = address(1)
whileinitializeImmutables()
requiresfactory == address(0)
to proceed. This creates a paradox. The initialization protection mechanism conflicts with the proxy pattern design, creating a deadlock where the very check meant to protect initialization makes it impossible.Impact
The problem stems from a contradiction in the initialization logic. The constructor immediately sets
factory = address(1)
, but theinitializeImmutables
function requiresfactory == address(0)
to proceed. This creates a logical impossibility - the initialization function can never be called successfully because its primary guard condition can never be satisfied.Scenario
Let's walk through the execution flow:
This permanently sets the factory address to 1. The comment suggests this is intended to "disable immutables initialization", but this creates issues with the proxy pattern implementation.
initializeImmutables
, the first check is:This check will always fail because
factory
is already set toaddress(1)
. The error "AII" (Already Initialized Immutables) will be thrown in every case.This becomes particularly problematic when considering the contract's intended usage with proxy patterns, as indicated by the comment:
Fix
Remove the constructor initialization of factory since it's breaking the proxy initialization pattern:
The initialization check in
initializeImmutables()
can stay as is:The fixed version is better because:
require(factory == address(0))
check is sufficient for ensuring single initializationThis allows the proxy deployment pattern to work as intended while maintaining the one-time initialization guarantee through the zero-address check.
Assessed type
Context
The text was updated successfully, but these errors were encountered: