Dysfunctional CToken._acceptAdmin due to lack of function to assign pendingAdmin
The CToken contract includes an _acceptAdmin function that requires the caller to be pendingAdmin, but no function exists to set pendingAdmin, so it remains address(0). As a result, the admin can never be changed through this function.
Submitted by rayn, also found by 0x1f8b, cmichel, and Sleepy
The implementation of CToken in Duality introduced an _acceptAdmin function, which presumably should allow changing the admin. However, there does not exist a pairing proposePendingAdmin function that can propose a new pendingAdmin, thus pendingAdmin will never be set. This renders the _acceptAdmin function useless.
Proof of Concept
_acceptAdmin requires msg.sender to equal pendingAdmin, however, since pendingAdmin can never be set, it will always be address(0), making this function unusable.
function _acceptAdmin() external returns (uint256) {
// Check caller is pendingAdmin and pendingAdmin ≠ address(0)
if (msg.sender != pendingAdmin || msg.sender == address(0)) {
return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);
}
// Save current values for inclusion in log
address oldAdmin = admin;
address oldPendingAdmin = pendingAdmin;
// Store admin with value pendingAdmin
admin = pendingAdmin;
// Clear the pending value
pendingAdmin = address(0);
emit NewAdmin(oldAdmin, admin);
emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);
return uint256(Error.NO_ERROR);
}
Tools Used
vim, ganache-cli
Recommended Mitigation Steps
Add a proposePendingAdmin function where the current admin can propose successors.
function _proposePendingAdmin(address newPendingAdmin) external {
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.PROPOSE_PENDING_ADMIN_CHECK);
}
address oldPendingAdmin = pendingAdmin;
pendingAdmin = newPendingAdmin;
emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);
return uint256(Error.NO_ERROR)
}
0xdramaone (Duality Focus) confirmed and commented:
Acknowledged, we were aware this matches the behavior of actual compound when deployed with CErc20Immutable. We originally thought we would stick with this functionality, but have now opted for enabling admin transitions.
0xdramaone (Duality Focus) resolved
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 contract implements _acceptAdmin but omits the corresponding proposePendingAdmin function, leaving pendingAdmin permanently unset.
Impact
The admin role cannot be transferred, so administrative control remains permanently with the initial admin and cannot be handed over.
What the attacker needed
None
The fix
A proposePendingAdmin function should be added so the current admin can set a successor, enabling admin transitions.
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 is a special account with extra powers. This contract has a function to hand over admin rights, but it only works if a 'pending admin' has been set first. Because no function sets that pending admin, the handover can never happen.
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.