Skip to content
Access control Audit finding Beginner

Risk of losing admin access if `updateAdmin set with same current admin address

The updateAdmin function revokes the old admin's DEFAULT_ADMIN_ROLE even when the new admin address is the same as the current one, causing the protocol to lose admin control over the StaderConfig contract. An attacker could not exploit this directly, but a mistaken call by the admin would lock the contract's admin functions.

ksk2345 Follow with ChrisTina and NoamYakov

Originally disclosed on Code4rena

Submitted by ksk2345, also found by ChrisTina and NoamYakov

Current admin will lose DEFAULT_ADMIN_ROLE role if updateAdmin issued with same address.

There is a possibility of loss of protocol admin access to the critical StaderConfig.sol contract, if updateAdmin() is set with same current admin address by mistake.

Proof of Concept

Contract : StaderConfig.sol. Function : function updateAdmin(address _admin).

Using Brownie python automation framework commands in below examples:

  • Step #1 After initialization, admin-A is the admin which has the DEFAULT_ADMIN_ROLE.
  • Step #2 update new Admin: StaderConfig.updateAdmin(admin-B, {'from':admin-A}). The value of StaderConfig.getAdmin() is admin-B.
  • Step #3 admin-B updates admin to itself again: StaderConfig.updateAdmin(admin-B, {'from':admin-B}). The value of StaderConfig.getAdmin() is admin-B, but the DEFAULT_ADMIN_ROLE is revoked due to _revokeRole(DEFAULT_ADMIN_ROLE, oldAdmin). Now the protocol admin control is lost for StaderConfig contract.

Recommended Mitigation Steps

Reference: https://github.com/code-423n4/2023-06-stader/blob/7566b5a35f32ebd55d3578b8bd05c038feb7d9cc/contracts/StaderConfig.sol#L177 In the updateAdmin() function, add a check for oldAdmin != _admin, like below:

    address oldAdmin = accountsMap[ADMIN];
+   require(oldAdmin != _admin, "Already set to admin");

Assessed type

Access Control

Picodes (judge) decreased severity to Medium

manoj9april (Stader) confirmed and commented:

Sure, we will fix this.

rvierdiyev (warden) commented:

Isn’t this same as just transferring roles to the address 0 or any other address? Why would the protocol need to change roles to same address? Isn’t this an informative issue?

Co0nan (warden) commented:

I believe this falls under the “Admin Privilege” category, as such an issue should be marked as QA based on C4 docs and how similar issues got judged.

Picodes (judge) commented:

@rvierdiyev and @Co0nan - I respectfully disagree:

  • This is not an occurrence of “Admin Privilege”, which are issues where a privileged role uses their position to grief the protocol. Here, there is clearly a slight bug in the code.
  • We could argue that transferring the role to the same address is very unlikely but it is not an error in itself. The function clearly does not behave as intended in this case.
  • If you combine this with the fact that in initialize there is no call to setAccount(ADMIN, _admin); see here. It becomes actually likely that the admin calls this function for themselves.

Picodes (judge) commented:

@Co0nan - for information, “Admin Privilege” aren’t always QA, it depends on the context and is up to the judge. See here and here for the ongoing discussion about this.

Co0nan (warden) commented:

Here there is clearly a slight bug in the code.

@Picodes - This bug occurs from Admin as they pass an address twice. I have to stand with @rvierdiyev. This is likely due to missing Zero address Check on onlyOwner functions.

However, it’s up to you as the Judge and I respect your final conclusion.

sanjay-staderlabs (Stader) commented:

This is fixed in the code.


The original report as published on Code4rena, by ksk2345. 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 updateAdmin function unconditionally revokes the DEFAULT_ADMIN_ROLE from the old admin before granting it to the new admin, without checking if the new admin is the same as the old one.

Impact

The protocol could permanently lose admin control over the StaderConfig contract, making critical administrative functions inaccessible.

What the attacker needed

Admin calls updateAdmin with same address

The fix

The updateAdmin function should include a check to ensure the new admin address is different from the current admin address.

How it was found

  1. After initialization, admin-A has the DEFAULT_ADMIN_ROLE.
  2. admin-A calls updateAdmin to set admin-B as the new admin.
  3. admin-B calls updateAdmin to set admin-B (itself) as the new admin again.
  4. The DEFAULT_ADMIN_ROLE is revoked from admin-B, leaving no admin.

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 smart contracts, an admin role gives special permissions. If the admin calls a function to change the admin to the same address, the code first removes the old admin role and then tries to give it to the new admin, but since it's the same address, the role is lost. This means no one has admin rights anymore, and critical functions become unusable.

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 from Stader Labs

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.