The HooksFactory.deployMarketAndHooks function is used to deploy a hooks instance and a new market using the deployed hooks instance. In this function when the hooks instance is deployed the following check is performed on the HooksTemplate to check whether it exists.
HooksTemplate memory templateDetails = _templateDetails[hooksTemplate]; //@audit-info - get the HooksTemplate struct
if (!templateDetails.exists) {
revert HooksTemplateNotFound();
}
hooksInstance = _deployHooksInstance(hooksTemplate, hooksTemplateArgs);
The above check ensures that the provided hooksTemplate is valid and does exist to be used in the market deployment.
The HooksFactory.deployMarket function is also used for the market deployment. But the issue is that the template details of the hooksTemplate used for the market deployment in this function is not checked for templateDetails.exists flag.
Impact
As a result of the above vulnerability, even when the templateDetails.exists == false the market deployment will proceed without any revert, thus enabling invalid hooks templates to be used for the market deployments. Hence this vulnerability breaks the intended behavior of the protocol.
Hence it is recommended to update the HooksFactory.deployMarket function to check for the !templateDetails.exists flag before the _deployMarket is called, and revert the transaction if the templateDetails.exists == false. This will ensure that invalid hooks templates are not used for the market deployments.
Lines of code
https://github.com/code-423n4/2024-08-wildcat/blob/main/src/HooksFactory.sol#L506-L515 https://github.com/code-423n4/2024-08-wildcat/blob/main/src/HooksFactory.sol#L530-L544
Vulnerability details
Vulnerability Details
The
HooksFactory.deployMarketAndHooks
function is used to deploy a hooks instance and a new market using the deployed hooks instance. In this function when thehooks instance is deployed
the following check is performed on theHooksTemplate
to check whether itexists
.The above check ensures that the provided
hooksTemplate
is valid and does exist to be used in the market deployment.The
HooksFactory.deployMarket
function is also used for the market deployment. But the issue is that thetemplate details
of thehooksTemplate
used for the market deployment in this function is not checked fortemplateDetails.exists
flag.Impact
As a result of the above vulnerability, even when the
templateDetails.exists == false
the market deployment will proceed without any revert, thus enabling invalidhooks templates
to be used for the market deployments. Hence this vulnerability breaks the intended behavior of the protocol.Proof of Concept
https://github.com/code-423n4/2024-08-wildcat/blob/main/src/HooksFactory.sol#L506-L515
https://github.com/code-423n4/2024-08-wildcat/blob/main/src/HooksFactory.sol#L530-L544
Recommended Mitigation Steps
Hence it is recommended to update the
HooksFactory.deployMarket
function to check for the!templateDetails.exists
flag before the_deployMarket
is called, and revert the transaction if thetemplateDetails.exists == false
. This will ensure that invalidhooks templates
are not used for the market deployments.Assessed type
Other