code-423n4 / 2024-01-renft-findings

2 stars 0 forks source link

Long period self rents will block hook disabling #612

Closed c4-bot-8 closed 8 months ago

c4-bot-8 commented 8 months ago

Lines of code

https://github.com/re-nft/smart-contracts/blob/main/src/policies/Stop.sol#L194-L212

Vulnerability details

Impact

The protocol has admin-owned hooks, which can be used instead of _checkTransaction from GnosisSafe to disable transferring and approving the rented assets. There can be cases where hooks can contain vulnerable code in their onTransaction function and admins should disable them. Still, a malicious user can effectively block them from disabling by creating a rent to himself with a long rent period. As there will most likely be other rents using these hooks, admins will be forced to call updateHookStatus for onStop and all funds will be locked inside the PaymentEscrow contract, with no way to be recovered.

Proof of Concept

Stop.sol#L211

function _removeHooks(
    Hook[] calldata hooks,
    Item[] calldata rentalItems,
    address rentalWallet
) internal {
    // Define hook target, item index, and item.
    address target;
    uint256 itemIndex;
    Item memory item;

    // Loop through each hook in the payload.
    for (uint256 i = 0; i < hooks.length; ++i) {
        // Get the hook address.
        target = hooks[i].target;

        // Check that the hook is reNFT-approved to execute on rental stop.
        if (!STORE.hookOnStop(target)) { 
-->         revert Errors.Shared_DisabledHook(target); //@audit will revert if hook onStop function is disabled
        }

Tools Used

Manual Review

Recommended Mitigation Steps

Consider adding a blacklist to disable hooks only for certain renters, this will ensure that other users who are using the same hook will be able to stop their rents, without losing their funds.

Assessed type

Context

c4-pre-sort commented 8 months ago

141345 marked the issue as sufficient quality report

141345 commented 8 months ago

intentionally retain malicious hook, onStop function will be affected to lock fund

c4-pre-sort commented 8 months ago

141345 marked the issue as primary issue

c4-sponsor commented 8 months ago

Alec1017 (sponsor) confirmed

c4-judge commented 8 months ago

0xean marked the issue as satisfactory

c4-judge commented 8 months ago

0xean marked the issue as selected for report

akshaysrivastav commented 8 months ago

Hey @0xean thanks for judging this. I think this report needs a revisit.

Can you please recheck the impact, validity and duplication status of this report. Thanks.

Slavchew commented 8 months ago

Hi @akshaysrivastav,

Now leave it to @0xean to conclude if this is another path and a different issue or if it's a duplicate, but it's definitely valid.

0xEVom commented 8 months ago

Agree that this is just another way of framing #501.

Seems like two sides of the same coin to me.

c4-judge commented 8 months ago

0xean marked the issue as duplicate of #501

0xean commented 8 months ago

agree, should be duped.

c4-judge commented 8 months ago

0xean marked the issue as not selected for report