No Transfer Ownership Pattern
The contract's ownership transfer function allows the owner to accidentally transfer ownership to an invalid or uncontrolled address, which would break all functions restricted to the owner. An attacker could not directly exploit this, but the mistake could render the contract unusable.
Submitted by defsec, also found by Ruhum, elprofesor, pauliax, Reigada, and mics
Impact
The current ownership transfer process involves the current owner calling Swap.transferOwnership(). This function checks the new owner is not the zero address and proceeds to write the new owner’s address into the owner’s state variable. If the nominated EOA account is not a valid account, it is entirely possible the owner may accidentally transfer ownership to an uncontrolled account, breaking all functions with the onlyOwner() modifier.
Proof of Concept
- Navigate to ”https://github.com/code-423n4/2021-11-bootfinance/blob/7c457b2b5ba6b2c887dafdf7428fd577e405d652/customswap/contracts/Swap.sol#L30”
- The contract has many
onlyOwnerfunction. - The contract is inherited from the Ownable which includes
transferOwnership.
Tools Used
None
Recommended Mitigation Steps
Implement zero address check and consider implementing a two step process where the owner nominates an account and the nominated account needs to call an acceptOwnership() function for the transfer of ownership to fully succeed. This ensures the nominated EOA account is a valid and active account.
chickenpie347 (Boot Finance) confirmed
upgrading to med severity as this could impact availability of protocol
2 — Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.
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 ownership transfer function lacks a two-step process and a check that the new owner is a valid, active account.
Impact
The protocol's availability could be impacted because ownership might be transferred to an invalid account, breaking owner-only functions.
What the attacker needed
Owner calls transferOwnership; new owner address is invalid or uncontrolled
The fix
The ownership transfer should be fixed by implementing a two-step process where the owner nominates an account and the nominated account must call an acceptOwnership function.
How it was found
- Navigate to the Swap contract source code.
- Observe that the contract has many functions with the onlyOwner modifier.
- Note that the contract inherits from Ownable, which includes transferOwnership.
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 smart contract has an owner who can do special things. The owner can give ownership to someone else, but if they type the wrong address, the contract can get stuck because no one can use the owner-only features anymore. This is a design flaw, not an attack.
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.