initialize
will never execute in KatanaV3Factory
and KatanaV3Pool
#26
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
primary issue
Highest quality submission among a set of duplicates
🤖_100_group
AI based duplicate group recommendation
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
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/KatanaV3Factory.sol#L46-L47
https://github.com/ronin-chain/katana-v3-contracts/blob/03c80179e04f40d96f06c451ea494bb18f2a58fc/src/core/KatanaV3Pool.sol#L117
Vulnerability details
Proof of Concept
This vulnerability can be found in both
KatanaV3Factory::initialize
andKatanaV3Pool::initializeImmutables
However, let us take a look at
KatanaV3Factory::initialize
from the code below, we can observe that in the constructorbeacon=address(1)
which causesinitialize
not to execute but revert on the require statement.why? This is because when you look at the function the first line in the body is a require statement that makes sure our
beacon==address(0)
but from our constructor you can see the beacon is already initialised to address(1) there by causing the require statement to always revert.When this happens this will cause the
onlyOwner
modifier to always revert sinceowner
has not been initialized and the_checkOwner
will revert. This further causes all onlyOwner functions to be unusable.Looking at the
KatanaV3Pool::initializeImmutables
which has the same vulnerability present we can further confirm from the docs/natspec we can confirm that theinitializeImmutables
is meant to be called once during deployment.but from our analysis earlier we can also conclude that this function will never run because of the constructor which sets
factory=address(1)
and the require statement that will always revert becausefactory
is not address(0).Recommended Mitigation Steps
Implement a new logic in such a way that contract can only be initialized once.
Assessed type
Other
The text was updated successfully, but these errors were encountered: