Previous owner still hold manager role after ownership transfer
The Manager contract does not automatically revoke the previous owner's manager role when ownership is transferred. If the previous owner's account is compromised, an attacker could use the retained manager privileges to call reward distribution functions and redirect rewards to their own address.
Originally disclosed on Immunefi
- Disclosed after under an hour
#41659 [SC-Insight] Previous owner still hold manager role after ownership transfer
Submitted on Mar 17th 2025 at 11:19:43 UTC by @merlinboii for Audit Comp | Yeet
- Report ID: #41659
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/StakeV2.sol
- Impacts:
Description
Brief/Intro
The Manager contract allows previous owners to retain their manager role even after ownership transfer. This could lead to unauthorized access to manager's privileged functions: executeRewardDistributionYeet() and executeRewardDistribution(). If proper role cleanup is not performed manually, potentially compromising the protocol's access control system.
Vulnerability Details
Manager roles handling in the Manager contract are not automatically revoked during ownership transfer:
- In the constructor, both owner and manager get manager roles:
constructor(address _owner, address _manager) Ownable(_owner) {
managers[_owner] = true;
managers[_manager] = true;
}
- When ownership is transferred using Ownable's
transferOwnership, the previous owner's manager status remains as there is no override logic to cleanup of manager roles: - The
removeManagerfunction exists but must be called manually:
function removeManager(address _manager) external override onlyOwner {
require(managers[_manager], "Manager does not exist");
require(_manager != address(0), "Invalid address");
managers[_manager] = false;
}
Impact Details
This could be considered a Security best practicesassuming that all setup roles are trusted, including the previous owner, who was trusted before the transfer.
However, if the previous owner was compromised and their address has not yet been removed from the manager role, it creates an opportunity for an attacker to frontrun the removeManager() and operate crucial functions.
References
https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/StakeV2.sol#L35-L59
Proof of Concept
Proof of Concept
- During deployment, Trusted-Owner-A (EOA) is used as the deployer of the contract and holds both owner and manager roles
- After setup is complete, ownership is transferred from Trusted-Owner-A to Trusted-Owner-B (The Multisig)
- Trusted-Owner-A retains their manager role
- Over time, if Trusted-Owner-A's account becomes compromised or experiences key leakage, attacker can still race to call
executeRewardDistributionYeet()andexecuteRewardDistribution()to distribute and redirect reward distributions to their own addresses (by settingvaultParams.receiver != StakeV2)
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 ownership transfer function does not automatically remove the previous owner from the managers mapping, and the removal must be done manually via a separate function.
Impact
If the previous owner's account is compromised, an attacker could call reward distribution functions to redirect rewards to their own addresses, but this requires the previous owner to be compromised and the manager role not manually removed.
What the attacker needed
Previous owner's account compromised; manager role not manually removed
The fix
The contract should automatically remove the previous owner's manager role during ownership transfer, or the transfer process should include a mandatory call to removeManager.
How it was found
- Deploy the contract with a trusted owner who also gets the manager role.
- Transfer ownership to a new owner (e.g., a multisig).
- The previous owner still has the manager role.
- If the previous owner's account is compromised, an attacker can call reward distribution functions to redirect rewards.
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, roles like 'owner' and 'manager' give special permissions. When ownership changes, the old owner should lose all special rights, but here they keep the manager role unless someone manually removes it. If that old account is later hacked, the attacker can still use those manager powers to redirect rewards.
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.