Closed c4-bot-1 closed 10 months ago
141345 marked the issue as duplicate of #501
0xean marked the issue as satisfactory
@0xean I can definitely see how this submission was marked as a duplicate of #501 since they look very similar on the surface, but this one centers on a different issue and I would greatly appreciate it if you could consider it separately. Here's how both issues differ:
onStop
also need to be whitelisted for onStart
in order to create a rental, and all hooks whitelisted for onStart
need to be whitelisted for onStop
in order to stop a rental. As such, it is impossible to create and whitelist hooks with the intended granularity.leaving them as dupes, underlying issue is the same
Lines of code
https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/policies/Create.sol#L480-L482 https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/policies/Stop.sol#L209-L212
Vulnerability details
Impact
The reNFT protocol uses hooks, which can act as middleware to a target contract or execute during rental start or stop. The
updateHookStatus()
function in theStorage
module allows the admin to set the permissions of a hook using a bitmap consisting of 3 bits, which represent whether theonTransaction()
,onStart()
andonStop()
functions are whitelisted for a given module, respectively: https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/modules/Storage.sol#L313-L326https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/modules/Storage.sol#L144-L172
However, the current implementation requires hook to always succeed on both
onStart()
andonStop()
calls if they are provided in an order. This means if a hook is only whitelisted foronStop()
, it will not be possible to create rentals using it as theaddHooks()
function, called during the creation of a rental, will revert: https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/policies/Create.sol#L480-L482Conversely, if a hook is provided for
onStart()
but isn't whitelisted foronStop()
, it will prevent the rental from being stopped. This is because the_removeHooks()
function, which is called formstopRent()
andstopRentBatch()
on rental termination, will revert if any of the hooks in the order is not whitelisted foronStop()
: https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/policies/Stop.sol#L209-L212This could lead to a situation where a rental cannot be stopped because a hook used in the
onStart()
phase is not whitelisted foronStop()
, which would lock assets in the safe and prevent users from reclaiming their assets.Proof of Concept
We can validate the issue through an additional test case for the
WhitelistedFulfillment.t.sol
test file, which will perform the following actions:onStart()
calls only.onStop()
, thestopRent()
function should revert with an error, confirming the issue.The following test case follows the steps outlined above:
Tools Used
Manual review, Foundry
Recommended Mitigation Steps
A potential solution to this issue could be to modify the
_addHooks()
and_removeHooks()
functions to ignore hooks that aren't whitelisted, instead of reverting. This would allow rentals to be created and stopped even if a hook is not whitelisted for both phases.Assessed type
Other