Skip to content
Access control Audit finding Intermediate

Role providers can bypass intended restrictions and lower expiry set by other providers

A role provider could bypass the intended restriction that prevents it from lowering a credential's expiry set by another provider. By first extending the expiry slightly and then reducing it, the provider could shorten a user's role duration, potentially affecting a lender.

deadrxsezzz Follow with 0x1771 and gesha17

Originally disclosed on Code4rena

Submitted by deadrxsezzz, also found by 0x1771 and gesha17

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

If we look at the code comments, we’ll see that role providers can update a user’s credential only if at least one of the 3 is true:

  • the previous credential’s provider is no longer supported, OR
  • the caller is the previous role provider, OR
  • the new expiry is later than the current expiry
  /**
   * @dev Grants a role to an account by updating the account's status.
   *      Can only be called by an approved role provider.
   *
   *      If the account has an existing credential, it can only be updated if:
   *      - the previous credential's provider is no longer supported, OR
   *      - the caller is the previous role provider, OR
   *      - the new expiry is later than the current expiry
   */
  function grantRole(address account, uint32 roleGrantedTimestamp) external {
    RoleProvider callingProvider = _roleProviders[msg.sender];

    if (callingProvider.isNull()) revert ProviderNotFound();

    _grantRole(callingProvider, account, roleGrantedTimestamp);
  }

This means that a role provider should not be able to reduce a credential set by another role provider.

However, this could easily be bypassed by simply splitting the call into 2 separate ones:

  1. First one to set the expiry slightly later than the currently set one. This would set the role provider to the new one.
  2. Second call to reduce the expiry as much as they’d like. Since they’re the previous provider they can do that.

Recommended Mitigation Steps

Fix is non-trivial.

d1ll0n (Wildcat) disputed and commented:

This is a useful note to be aware of, but I’d categorize it low/informational as role providers are inherently trusted entities. The likelihood and impact of this kind of attack are pretty minimal.

3docSec (judge) commented:

There are a few factors to be considered:

  • it is a valid privilege escalation vector
  • the attacker has to be privileged already
  • the attack can have a direct impact on a lender

While the first two have me on the fence when choosing between Medium and Low severity, the third point is a tiebreaker towards Medium.

If we stick to the C4 severity categorization, I see a good fit with the Medium definition:

“the function of the protocol or its availability could be impacted […] with a hypothetical attack path with stated assumptions”


The original report as published on Code4rena, by deadrxsezzz. 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 check only compares the new expiry with the current expiry and does not prevent a provider from first extending and then reducing the expiry in separate calls.

Impact

A role provider could reduce the expiry of a credential set by another provider, which may impact a lender.

What the attacker needed

Caller is an approved role provider

The fix

The fix is non-trivial and not specified in the text.

How it was found

  1. Call grantRole with an expiry slightly later than the current one to become the previous provider.
  2. Call grantRole again with a reduced expiry to lower the credential's expiry.

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 system, role providers are trusted accounts that grant roles to users. The code tries to stop one provider from shortening a role that another provider gave, but a provider can get around this by making two separate updates: first extending the expiry a little, then shortening it as much as they want.

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 deadrxsezzz

View all

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