Skip to content
Access control Audit finding Intermediate

The owners of a rental safe can continue to use the old guard policy contract for as long as they want, regardless of a new guard policy upgrade

The Guard policy contract used by rental safes did not check whether it was still active in the Kernel, so a safe could keep using an outdated guard after an upgrade. This allowed transactions that the new guard would block to still be permitted in safes that had not migrated.

oakcobalt Follow with m4ttm and ladboy233

Originally disclosed on Code4rena

Submitted by oakcobalt, also found by m4ttm and ladboy233

Policy contracts such as Guard.sol can be upgraded when needed. However, there is a vulnerability in existing implementation of Guard policy, that allows a rental safe contract to use the outdated Guard.sol for an unlimited amount of time.

This compromises the security of the rental wallet because unsafe transactions that are checked and reverted in the new guard policy contract can be directly bypassed and permitted in rental safe contract using an old guard policy.

Proof of Concept

Policy contracts can be upgraded by protocol executor on Kernel.sol through executeAction() -> _activatePolicy() -> _deactivePolicy(). When Guard.sol needs to be upgraded, the intended flow is a) _activatePolicy(newGuard) b) _deactivePolicy(oldGuard), c) admin will whitelist a temporary migration contract which allows any rental safe wallet to make a delegate call to migration contract to upgrade the guard address in storage. This flow can also be confirmed in test: test/integration/upgradeability/GuardPolicyUpgrade.t.sol.

Note in this intended flow, the rental safe contract owner needs to initiate a delegate call to the whitelisted migration contract to update the pointer to the new guard address.

However, the issue is (1) there is no enforcement that an existing rental safe contract owner will call the migration contract to upgrade their guard address; (2) even if the safe owner doesn’t call to update their guard address, the rental safe will be able to continue to use the old guard contract to execute transactions, bypassing any new restrictions that might be enforced in the new guard.

This is because current Guard.sol’s key user flows that involve _checkTransactions(), _forwardToHook(),_revertNonWhiteListedExtensions() won’t check if the existing Guard.sol address stored in the safe contract is still active, and these flows will only call Storage.sol’s view functions or public variables that have no access control to revert when the caller Guard.sol is no longer active in Kernel.

As a result, even though the active Guard.sol in Kernel.sol is a different address and the old guard doesn’t exist in Kernel’s storage, all the rental safe flows can still use the old guard to check transactions.

//src/policies/Guard.sol
    function checkTransaction(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation,
        uint256,
        uint256,
        uint256,
        address,
        address payable,
        bytes memory,
        address
    ) external override {
        // Disallow transactions that use delegate call, unless explicitly
        // permitted by the protocol.
|>      //@audit There are no checks to see if address(this) (guard) is still active in Kernel.sol
        //@audit note: when Guard.sol is no longer active, STORE.whitelistedDelegates(to) will still pass, because it's a view funciton with no access control
|>      if (operation == Enum.Operation.DelegateCall && !STORE.whitelistedDelegates(to)) {
            revert Errors.GuardPolicy_UnauthorizedDelegateCall(to);
        }
        // Require that a function selector exists.
        if (data.length < 4) {
            revert Errors.GuardPolicy_FunctionSelectorRequired();
        }
        // Fetch the hook to interact with for this transaction.
        //@audit note: when Guard.sol is no longer active, STORE.contractToHook(to) and STORE.hookOnTransaction(hook) because they are view functions with no access control
|>      address hook = STORE.contractToHook(to);
|>      bool isActive = STORE.hookOnTransaction(hook);
        // If a hook exists and is enabled, forward the control flow to the hook.
        if (hook != address(0) && isActive) {
            _forwardToHook(hook, msg.sender, to, value, data);
        }
        // If no hook exists, use basic tx check.
        else {
            _checkTransaction(msg.sender, to, data);
        }
    }

(https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/policies/Guard.sol#L324-L331)

//src/policies/Guard.sol
    function _checkTransaction(address from, address to, bytes memory data) private view {
...
            //@audit when Guard.sol is no longer active in Kernel, _revertSelectorOnActiveRental() will still work because it only calls view functions with no access control.
|>          _revertSelectorOnActiveRental(selector, from, to, tokenId);
...
            //@audit when Guard.sol is no longer active in Kernel, _revertNonWhitelistedExtension() will still work because it only calls view function with no access control
|>          _revertNonWhitelistedExtension(extension);
    }

    function _revertSelectorOnActiveRental(
        bytes4 selector,
        address safe,
        address token,
        uint256 tokenId
    ) private view {
        // Check if the selector is allowed.
        //@audit when Guard.sol is no longer active in Kernel, STORE.isRentedOut() will still work because it only calls view function with no access control
|>      if (STORE.isRentedOut(safe, token, tokenId)) {
            revert Errors.GuardPolicy_UnauthorizedSelector(selector);
        }
    }

    function _revertNonWhitelistedExtension(address extension) private view {
        // Check if the extension is whitelisted.
        //@audit when Guard.sol is no longer active in Kernel, STORE.whitelistedExtensions() will still work because it only calls view function with no access control
|>       if (!STORE.whitelistedExtensions(extension)) {
            revert Errors.GuardPolicy_UnauthorizedExtension(extension);
        }
    }

(https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/policies/Guard.sol#L133) (https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/policies/Guard.sol#L145)

In addition, this creates a condition where the behaviors of different rental safe contracts can be uneven, depending on whether a specific rental safe is using a new guard or old guard, they might have different levels of restrictions in executions, which undermines the fairness in the rental process. For example, some new function selectors can be prohibited from execution in the new guard based on the protocol needs, but these selectors will continue to be allowed in rental safes that use the old guard.

For comparison, a rental safe using an old Stop policy (Stop.sol) will cause revert at stopRent() or stopRentBatch() flow due to failing permissioned function sig checks, which will force safe owners to migrate to the new Stop.sol. But an old Guard policy allows safe owners to continue using an outdated checkTransaction() logics, which I consider it high severity.

Recommended Mitigation Steps

In checkTransaction() , call Kernal.sol to check whether address(this) ( Guard.sol that the safe is pointing to) is still active. This can be done by calling uint256 index = kernel.getPolicyIndex(address(this)) and then check if the index corresponds to address(this) in kernel.activePolicies.

Alec1017 (reNFT) confirmed

0xean (Judge) decreased severity to Medium and commented:

This compromises the security of the rental wallet because unsafe transactions that are checked and reverted in the new guard policy contract can be directly bypassed and permitted in rental safe contract using an old guard policy.

The warden doesn’t show how this directly leads to loss of funds. I think this falls into:

but the function of the protocol or its availability could be impacted,

Therefore should be M.

reNFT mitigated:

The PR here - Introduces isActive check on the guard policy. Ensures that safes cannot use a guard that has been deactivated.

Status: Mitigation error. Full details in report from EV_om, and also included in the Mitigation Review section below.


The original report as published on Code4rena, by oakcobalt. 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

Likely the Guard contract's transaction checks did not verify that the guard itself was still an active policy in the Kernel, relying only on view functions without access control.

Impact

Unsafe transactions that the new guard would block could still be permitted in safes using the old guard, potentially compromising the security of the rental wallet, though the report does not demonstrate direct loss of funds.

What the attacker needed

A rental safe exists; the Guard policy is upgraded; the safe owner does not migrate

The fix

The Guard contract should check with the Kernel that it is still an active policy before allowing transactions.

How it was found

  1. Deploy a new Guard policy and activate it in the Kernel.
  2. Deactivate the old Guard policy in the Kernel.
  3. Do not call the migration contract to update the guard address in an existing rental safe.
  4. The rental safe continues to use the old Guard for transaction checks, bypassing new restrictions.

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 guard is a security check that approves or blocks transactions for a rental safe. When the guard is upgraded, old safes were supposed to switch to the new one, but nothing forced them to. So an old safe could keep using the old guard, which might allow actions the new guard would stop.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by oakcobalt

View all

50 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.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.