High Risk in transfer of proxyOwnership
The proxy ownership transfer function lets the current owner set a new owner in a single step, with no check that the new address differs from the current one and no two-step confirmation. A malicious or careless operator could hand control to a compromised or invalid address, which the report says could lead to theft or permanent freezing of funds.
- Disclosed after under an hour
26431 - [SC - Insight] High Risk in transfer of proxyOwnership
Submitted on Dec 2nd 2023 at 22:05:37 UTC by @SentientX for Boost | DeGate
Report ID: #26431
Report type: Smart Contract
Report severity: Insight
Target: https://etherscan.io/address/0x54D7aE423Edb07282645e740C046B9373970a168#code
Impacts:
- Permanent freezing of funds from the Default Deposit Contract that requires malicious actions from the DeGate Operator.
- Theft of funds from the Default Deposit Contract that requires malicious actions from the DeGate Operator.
Description
Bug Description
The function:
function transferProxyOwnership(address newOwner) public onlyProxyOwner {
require(newOwner != address(0));
emit ProxyOwnershipTransferred(proxyOwner(), newOwner);
setUpgradabilityOwner(newOwner);
}
handles the transfer of ownership to new proxy owner, however the function fails to recognize two fundamental risks:
- Transfer of ownership to compromised current owner address
- Transfer of ownership to invalid address.
both of which can be caused by operational error or malicious actions of Degate Operator.
Risk 1 Scenario:
- Current owner address is compromised. (eg. private key leaked)
- In state of panic ownership is transferred to same owner
- Risk exposure has not changed
Risk 2 Scenario
- Current owner address is compromised
- In state of Panic transfer is made to in valid address
Impact
- Funds can be stolen if malicious Degate Operator transfers proxy to an address he controls
- Funds can be permanently locked up if an error in transfer is made to in valid address
Risk Breakdown
Difficulty to Exploit: Easy Weakness: CVSS2 Score:
Recommendation
- Consider use of 2-step transferOwnersip Proxy
- Ensure proxy address is not the same address as current owner
- transferProxyOwnership by changing pending owner to newOwner
example:
* @dev Allows the current owner to transfer control of the contract to a newOwner.
*changes the pending owner to newOwner. But doesn't actually transfer
* @param newOwner The address to transfer ownership to.
*/
function transferProxyOwnership(address newOwner) external onlyProxyOwner {
require(newOwner != address(0));
_setPendingUpgradeabilityOwner(newOwner);
emit NewPendingOwner(proxyOwner(), newOwner);
}
- Let pending Owner claim ownership:
/**
* @dev Allows the pendingOwner to claim ownership of the proxy
*/
function claimProxyOwnership() external onlyPendingProxyOwner {
emit ProxyOwnershipTransferred(proxyOwner(), pendingProxyOwner());
_setUpgradeabilityOwner(pendingProxyOwner());
_setPendingUpgradeabilityOwner(address(0));
}
Finally internal function,
function _setUpgradeabilityOwner(address newProxyOwner) internal {
bytes32 position = proxyOwnerPosition;
assembly {
sstore(position, newProxyOwner)
}
}
References
Reference implementation:
Proof of concept
- Current Proxy owner calls
transferProxyOwnership(address newOwner) public onlyProxyOwnersetting new owner to compromised address accidently or maliciously. - Protocol Default Deposit contract is compromised
- Funds Stolen or Funds Frozen
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 single-step ownership transfer lacks a two-step accept flow and a check that the new owner differs from the current one.
Impact
Funds could be stolen if a malicious operator transfers the proxy to an address they control, or permanently locked if the transfer goes to an invalid address; both depend on the operator acting maliciously or making an error.
What the attacker needed
Control of the proxy owner key; operator error or malicious intent
The fix
The report recommends a two-step transfer where the new owner is recorded as pending and must claim ownership, plus a check that the new address differs from the current owner.
How it was found
- The current proxy owner calls the ownership transfer function.
- The new owner is set to a compromised or invalid address, by mistake or on purpose.
- The default deposit contract is then under the wrong control.
- Funds are stolen or frozen.
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.
A proxy is a contract that holds the funds but passes calls to a logic contract, and whoever owns the proxy can swap that logic. This report says the owner can change the proxy owner in one step, so a mistake or a stolen key can put the funds under the wrong control. A safer pattern asks the new owner to accept the role before it takes effect.
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.