Excessive Authority Granted to Managers in the ckr_btc.cairo Contract Presents Significant Management Risks
Managers in the ckr_btc.cairo contract have excessive authority, including the ability to add new managers and assign operator roles. This could allow a single manager to expand control and potentially enable unauthorised token minting or burning.
joicygiore Follow with Abdessamed, Tigerfrake and 7 others
Originally disclosed on Code4rena
Submitted by joicygiore, also found by Abdessamed, Tigerfrake, m4k2, SBSecurity, devival, haxatron, said, fyamf, and peanuts
In the ckr_btc.cairo contract, managers possess broad authority and can execute all functions except upgrade(). This level of access contrasts with typical Solidity practices, where such functions would require owner privileges.
One of the primary concerns is that any existing manager has the ability to add new managers. This unchecked ability to expand the number of managers can lead to an uncontrolled increase in the number of authorized managers, creating a potential security risk. Without additional checks or approval mechanisms, this design flaw could be exploited, leading to a dilution of control and increased risk of unauthorized actions.
Furthermore, managers also have the ability to designate operator roles. Operators, in turn, have the authority to mint and burn tokens, which compounds the risk if these roles are not properly managed. This level of access could easily lead to a situation where control over critical functions is decentralized in a manner that might not have been intended by the original design.
It is unclear whether this design was intentional, but it introduces significant management risks that should be addressed.
fn add_manager(ref self: ContractState, new_manager: ContractAddress) -> bool {
let caller = get_caller_address();
@> assert(self.chakra_managers.read(caller) == 1, Errors::NOT_MANAGER);
assert(self.chakra_managers.read(new_manager) == 0, Errors::ALREADY_MANAGER);
self.chakra_managers.write(new_manager, 1);
self
.emit(
ManagerAdded {
operator: caller, new_manager: new_manager, added_at: get_block_timestamp()
}
);
return self.chakra_managers.read(new_manager) == 1;
}
fn add_operator(ref self: ContractState, new_operator: ContractAddress) -> bool {
let caller = get_caller_address();
@> assert(self.chakra_managers.read(caller) == 1, Errors::NOT_MANAGER);
assert(self.chakra_operators.read(new_operator) == 0, Errors::ALREADY_OPERATOR);
self.chakra_operators.write(new_operator, 1);
self
.emit(
OperatorAdded { new_operator: new_operator, added_at: get_block_timestamp() }
);
return self.chakra_operators.read(new_operator) == 1;
}
fn mint_to(ref self: ContractState, to: ContractAddress, amount: u256) -> bool {
let caller = get_caller_address();
@> assert(self.chakra_operators.read(caller) == 1, Errors::NOT_OPERATOR);
let old_balance = self.erc20.balance_of(to);
self.erc20.mint(to, amount);
let new_balance = self.erc20.balance_of(to);
return new_balance == old_balance + amount;
}
Impact
The excessive authority granted to managers poses a significant management risk. The potential for an uncontrolled expansion of manager roles, coupled with the ability to assign operator roles, could lead to serious security vulnerabilities, including unauthorized minting or burning of tokens.
Recommended Mitigation Steps
It is recommended to follow best practices as implemented in Solidity contracts, where only the owner has the authority to add or remove managers and operators. This can be achieved by modifying the current implementation to enforce owner checks when adding new managers or operators.
Example of a safer approach:
fn add_manager(ref self: ContractState, new_manager: ContractAddress) -> bool {
let caller = get_caller_address();
- assert(self.chakra_managers.read(caller) == 1, Errors::NOT_MANAGER);
+ self.ownable.assert_only_owner();
assert(self.chakra_managers.read(new_manager) == 0, Errors::ALREADY_MANAGER);
self.chakra_managers.write(new_manager, 1);
self
.emit(
ManagerAdded {
operator: caller, new_manager: new_manager, added_at: get_block_timestamp()
}
);
return self.chakra_managers.read(new_manager) == 1;
}
fn add_operator(ref self: ContractState, new_operator: ContractAddress) -> bool {
let caller = get_caller_address();
- assert(self.chakra_managers.read(caller) == 1, Errors::NOT_MANAGER);
+ self.ownable.assert_only_owner();
assert(self.chakra_operators.read(new_operator) == 0, Errors::ALREADY_OPERATOR);
self.chakra_operators.write(new_operator, 1);
self
.emit(
OperatorAdded { new_operator: new_operator, added_at: get_block_timestamp() }
);
return self.chakra_operators.read(new_operator) == 1;
}
zvlwwj (Chakra) confirmed via duplicate issue #107
The Warden and its duplicates have identified a potential privilege escalation exploitation path whereby a single manager can overtake the system by removing all others and then introducing malicious variants of themselves. I believe that this breaches the documentation of the system and is a form of privilege escalation as managers should collectively authorize operations.
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 contract allows any manager to add new managers and operators without requiring owner approval, leading to unchecked privilege expansion.
Impact
A single manager could potentially take over the system by adding malicious managers and operators, leading to unauthorised minting or burning of tokens.
What the attacker needed
Attacker is a manager
The fix
The contract should be modified so that only the owner can add or remove managers and operators, following Solidity best practices.
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, people called managers have a lot of power. They can add more managers and give out operator roles, which let people create or destroy tokens. If a manager misuses this, they could take over the system and do harmful things like making unlimited tokens.
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.