Skip to content
Access control Audit finding Intermediate

AccessControlHooks onQueueWithdrawal() does not check if market is hooked which could lead to unexpected errors such as temporary DoS

The onQueueWithdrawal function in AccessControlHooks does not verify that the caller is a hooked market, allowing anyone to call it with arbitrary hookData. This could let an attacker front-run a lender's withdrawal transaction by submitting the same credential, causing the honest transaction to revert and potentially leading to a temporary denial of service for markets using short-lived credentials.

gesha17 Follow with falconhoof, kutugu and 1 other

Originally disclosed on Code4rena

Submitted by gesha17, also found by falconhoof, kutugu, and Infect3d

Impact

The onQueueWithdrawal() function does not check if the caller is a hooked market, meaning anyone can call the function and attempt to verify credentials on a lender. This results in calls to registered pull providers with arbitrary hookData, which could lead to potential issues such as abuse of credentials that are valid for a short term, e.g. 1 block.

Proof of Concept

The onQueueWithdrawal() function does not check if the msg.sender is a hooked market, which is standart in virtually all other hooks:

https://github.com/code-423n4/2024-08-wildcat/blob/main/src/access/AccessControlHooks.sol#L812

  /**
   * @dev Called when a lender attempts to queue a withdrawal.
   *      Passes the check if the lender has previously deposited or received
   *      market tokens while having the ability to deposit, or currently has a
   *      valid credential from an approved role provider.
   */
  function onQueueWithdrawal(
    address lender,
    uint32 /* expiry */,
    uint /* scaledAmount */,
    MarketState calldata /* state */,
    bytes calldata hooksData
  ) external override {
    LenderStatus memory status = _lenderStatus[lender];
    if (
      !isKnownLenderOnMarket[lender][msg.sender] && !_tryValidateAccess(status, lender, hooksData)
    ) {
      revert NotApprovedLender();
    }
  }

If the caller is not a hooked market, the statement !isKnownLenderOnMarket[lender][msg.sender], will return true, because the lender will be unknown. As a result the _tryValidateAccess() function will be executed for any lender and any hooksData passed. The call to _tryValidateAccess() will forward the call to _tryValidateAccessInner(). Choosing a lender of arbitrary address, say address(1) will cause the function to attempt to retrieve the credential via the call to _handleHooksData(), since the lender will have no previous provider or credentials.

As a result, the _handleHooksData function will forward the call to the encoded provider in the hooksData and will forward the extra hooks data as well, say merkle proof, or any arbitrary malicious data.

https://github.com/code-423n4/2024-08-wildcat/blob/main/src/access/AccessControlHooks.sol#L617

  function _handleHooksData(
    LenderStatus memory status,
    address accountAddress,
    bytes calldata hooksData
  ) internal returns (bool validCredential) {
    // Check if the hooks data only contains a provider address
    if (hooksData.length == 20) {
      // If the data contains only an address, attempt to query a credential from that provider
      // if it exists and is a pull provider.
      address providerAddress = _readAddress(hooksData);
      RoleProvider provider = _roleProviders[providerAddress];
      if (!provider.isNull() && provider.isPullProvider()) {
        return _tryGetCredential(status, provider, accountAddress);
      }
    } else if (hooksData.length > 20) {
      // If the data contains both an address and additional bytes, attempt to
      // validate a credential from that provider
      return _tryValidateCredential(status, accountAddress, hooksData);
    }
  }

The function call will be executed in tryValidateCredential(), where the extra hookData will be forwarded. As described in the function comments, it will execute a call to provider.(address account, bytes calldata data).

This means that anyone can call the function and pass arbitrary calldata. This can lead to serious vulnerabilities as the calldata is passed to the provider.

Consider the following scenario:

  • The pull provider is implemented to provide a short-term(say one block) approval timestamp.
  • A user of the protocol provides a merkle-proof which would grant the one-time approval to withdraw in a transaction.
  • A malicious miner frontruns the transaction submitting the same proof, but does not include the honest transaction in the mined block. Instead it is left for the next block.
  • In the next block, the credential is no longer valid and as a result the honest user has their transaction revert.
  • The miner does this continuosly essentially DoSing the entire market that uses this provider until it is removed and a new one added.

By following this scenario, a malicious user can essentially DoS a specific type pull provider.

Depending on implemenation of the pull provider, this can lead to other issues, as the malicious user can supply any arbitrary hookData in the function call.

Recommended Mitigation Steps

Require the caller to be a registered hooked market, same as onQueueWithdrawal() in FixedTermloanHooks

3docSec (judge) commented via duplicate issue #83:

I find this group compatible with the Medium severity for the following reasons:

  • access to a lender’s signature is very feasible in the frontrunning scenario depicted in this finding
  • the hypothesis on validateCredential isn’t really a speculation but rather a very reasonable implementation, one that was also assumed in the previous audit (finding number 2).

laurenceday (Wildcat) acknowledged and commented:

We don’t consider this a real issue, in that we’ve always wanted it to be possible for anyone to call the validate function to poke a credential update. This finding assumes that you have the signature someone else would be using as a credential and generally relies on a specific implementation of the provider that doesn’t actually exist, so there’s no need to check isHooked.

It’s been upgraded to a Medium, and we’re not going to argue with this at this stage. As such, we’re acknowledging rather than confirming or disputing simply to put a cap on the report.


The original report as published on Code4rena, by gesha17. 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 function lacks a check that msg.sender is a registered hooked market, unlike other similar hooks.

Impact

A malicious user could temporarily deny service for markets using short-term pull providers, and depending on the provider implementation, other issues may arise from arbitrary hookData.

What the attacker needed

A pull provider with short-term credentials; Attacker can front-run transactions; Victim submits a withdrawal with a credential

How it was found

  1. A user submits a transaction with a merkle proof to withdraw, which includes a short-term credential.
  2. A malicious miner front-runs the transaction by calling onQueueWithdrawal with the same proof.
  3. The miner does not include the honest transaction in the mined block, leaving it for the next block.
  4. In the next block, the credential is no longer valid, so the honest user's transaction reverts.
  5. The miner repeats this to continuously deny service for that provider.

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.

In this smart contract system, a function that should only be called by a specific market contract can actually be called by anyone. This means an attacker can trigger checks on a user's credentials with made-up data, which might interfere with legitimate transactions. The issue is like a door that should only open for staff but is left unlocked for anyone.

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 gesha17

View all

4 more disclosed reports, best first.

More from The Wildcat Protocol

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.