Closed c4-submissions closed 1 year ago
minhquanym marked the issue as duplicate of #28
MarioPoneder marked the issue as not a duplicate
MarioPoneder changed the severity to QA (Quality Assurance)
Insufficent discussion of impact compared to former duplicates
MarioPoneder marked the issue as grade-c
Lines of code
https://github.com/code-423n4/2023-10-wildcat/blob/c5df665f0bc2ca5df6f06938d66494b11e7bdada/src/libraries/LibStoredInitCode.sol#L115 https://github.com/code-423n4/2023-10-wildcat/blob/c5df665f0bc2ca5df6f06938d66494b11e7bdada/src/WildcatMarketController.sol#L354 https://github.com/code-423n4/2023-10-wildcat/blob/c5df665f0bc2ca5df6f06938d66494b11e7bdada/src/WildcatMarketControllerFactory.sol#L297
Vulnerability details
Impact
deployMarket()
inWildcatMarketController.sol
anddeployController()
inWildcatMarketControllerFactory.sol
has used thecreate2
opcode which uses the salt and in turn allows the new contract to be deployed at a consistent, deterministic address. These function does not revert properly if there is a failed deployment or revert from thecreate2
opcode as it does not check the returned address for bytecode. The create2 opcode returns the expected address which will never be the zero address, However, rawcreate2
has been used inassembly
therefore it does not check the return value by default unlike used in solidity context.Proof of Concept
deployMarket()
inWildcatMarketController.sol
anddeployController()
inWildcatMarketControllerFactory.sol
under the hood has usedcreate2WithStoredInitCode()
fromLibStoredInitCode.sol
.and
create2WithStoredInitCode()
fromLibStoredInitCode.sol
has shown as below,As it can be seen it does not check the return value. Zero address check must be added to revert for
create2
if specifically used inassembly
The
CREATE2
opcode does not revert the transaction. Check the evm.codesTo understand, how it differs from using in solidity context to assembly context, Please refer this comment where the issue is explained with poc and remixIDE snapshot.
Tools Used
Manual review
Recommended Mitigation Steps
Check the return value of create2.
For example:
Assessed type
Other