Vulnerable Hook Detection
Vulnerable Hook Detection
The StopLoss contract leverages Uniswap V4’s custom user hook functionality to implement a stop loss feature. This hook automatically sells tokens when the price in a specified pool meets the user-defined stop-loss conditions, thereby preventing further losses. The functionality of this hook is summarized as follows:
Users create a stop-loss order by executing the placeStopLoss() function.
After each swap, the afterSwap function compares the previous and current ticks, executing the order if the conditions are met.
Let's take a look at the afterSwap function in this hook.
The function lacks a modifier and any additional ACL mechanism. Through this function, the fillStopLoss() function can be called separately, allowing storage values to be altered. This may lead to unexpected behavior in the hook, and appropriate measures are necessary. Herbicide can detect these risks and alert users accordingly.
This ArrakisHook stores information about the pool key in beforeInitialize right before initialization, enabling it to manage liquidity through ERC1155.
Let's take a look at the beforeInitialize()in this hook.
This contract is a hook implemented to initialize information about the pool key in beforeInitialize. However, this hook does not implement any access control for beforeInitialize, nor does it take any measures regarding the number of initializations. Since the pool key is initialized in beforeInitialize, if a new initialization is performed on this hook, all existing hook assets will be locked.
Herbicide detects the storage values of such cases to ensure that users can use the hook safely.