Skip to content
DoS Audit finding Intermediate

DoS of Rental stopping mechanism

The Guard contract allows administrators to disable the onStop hook, but if this is done after a rental is created with that hook, the stopRent function will always revert because it checks the hook status. This locks the lender's assets and ERC20 payments in the renter's safe and escrow contract.

AkshaySrivastav Follow with oakcobalt, SBSecurity and 18 others

Originally disclosed on Code4rena

Submitted by AkshaySrivastav, also found by EV_om (1, 2), oakcobalt, SBSecurity, 0xdice91, serial-coder, 0xDING99YA, imare, trachev, J4X (1, 2), rbserver, juancito, evmboi32, hals (1, 2), 0xA5DF, BARW (1, 2, 3, 4, 5), Jorgect, said, 0xAlix2 (1, 2), ZdravkoHr, BI_security, kaden, marqymarq10, rokinot, haxatron, and rvierdiiev

The Guard::updateHookStatus function is designed to allow protocol administrators to manage the status of hooks within the system. Hooks serve as essential components that customize and control flow of transactions within the protocol.

The vulnerability occurs when administrators disable the onStop hook using Guard::updateHookStatus. If the onStop hook gets disabled after a rental is created using that hook then that causes critical disruption in the rental closing flow.

This happens because the hook address is supplied by lender and renter at the time of rental creation, Both onStart and onStop gets executed on that user provided address at rental creation and stoppage respectively. Once a rental gets created its hook address cannot be modified. If the onStop hook gets disabled while the rental was active then the stopRent transaction will always revert.

        if (!STORE.hookOnStop(target)) {
            revert Errors.Shared_DisabledHook(target);
        }

https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/policies/Stop.sol#L210-L212

Proof of Concept

  1. Suppose the onStart and onStop hooks are initially set as active by administrators for a particular contract address.
  2. A user creates a rental transaction, and a whitelisted hook address is given as input.
  3. The onStart hook gets executed as part of the rental creation process.
  4. After some time, an administrator decides to disable the onStop hook for the same contract address.
  5. As a result, users are unable to stop the rental, as the onStop hook will always revert any attempt to do so.

This sequence of events can result in situations where rentals cannot be stopped due to the disabling of critical hooks, causing potential issues and disruptions within the protocol.

The assets of lender and ERC20 payments will remain stuck in the renter’s safe and escrow contract respectively.

Since this bug is dependent upon an admin interaction I am reporting it as medium.

The following foundry test shows the process described above. Add this test case in test/hooks/restricted-selector/RestrictedSelectorHook.t.sol file and run using command forge test --mp test/hooks/restricted-selector/RestrictedSelectorHook.t.sol.

Click to expand Foundry Test

 function test_toggle_hook_status() public {
     // create a bitmap that will disable the `train()` function selector
     uint256 bitmap = 1;

     // Define the hook for the rental
     Hook[] memory hooks = new Hook[](1);
     hooks[0] = Hook({
         target: address(hook),
         itemIndex: 0,
         extraData: abi.encode(bitmap)
     });

     // start the rental with hook.
     RentalOrder memory rentalOrder = _startRentalWithGameToken(1, hooks);
     bytes32 rentalOrderHash = create.getRentalOrderHash(rentalOrder);
     assertEq(STORE.orders(rentalOrderHash), true);

     // Admin disables the onStop hook
     vm.prank(deployer.addr);
     guard.updateHookStatus(address(hook), uint8(3));    // 011

     // User tries to stop the rental
     // But txn always reverts
     vm.warp(block.timestamp + 500);
     vm.prank(alice.addr);
     vm.expectRevert(abi.encodeWithSelector(
         Errors.Shared_DisabledHook.selector,
         address(hook)
     ));
     stop.stopRent(rentalOrder);
     assertEq(STORE.orders(rentalOrderHash), true);
 }

Recommended Mitigation Steps

Consider rethinking about the need of onStop hook status because if onStart hook is executed for a rental then the onStop hook must also be executed irrespective of the hook status.

Alec1017 (reNFT) confirmed

reNFT mitigated:

The PR here - onStart and onStop hook functions are now independent of one another and do not both need to be implemented at the same time.

Status: Mitigation confirmed. Full details in reports from juancito and sin1st3r__.


The original report as published on Code4rena, by AkshaySrivastav. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The stopRent function checks the current status of the onStop hook, but the hook address is fixed at rental creation and cannot be changed, so disabling the hook later permanently blocks stopping.

Impact

Rentals cannot be stopped, so the lender's assets and ERC20 payments remain stuck in the renter's safe and escrow contract.

What the attacker needed

Admin disables onStop hook after rental starts; rental created with that hook

The fix

The onStart and onStop hooks should be independent so that if onStart ran, onStop can still run regardless of its current status; the project mitigated this by making the two hook functions independent.

How it was found

  1. Administrators set the onStart and onStop hooks as active for a contract address.
  2. A user creates a rental with that whitelisted hook address.
  3. The onStart hook executes during rental creation.
  4. An administrator disables the onStop hook for the same contract address.
  5. The user tries to stop the rental, but the transaction reverts because the onStop hook is disabled.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A hook is a piece of code that runs automatically at certain times, like when a rental starts or stops. The system lets admins turn hooks on or off. If an admin turns off the stop hook after a rental has started, the rental can never be stopped, so the lender's items and payments get stuck.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by AkshaySrivastav

View all

16 more disclosed reports, best first.

More from reNFT

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.