Open code423n4 opened 1 year ago
minhquanym marked the issue as primary issue
minhquanym marked the issue as high quality report
In this scenario, renounceOwnership()
is initiated before setPendingOwner()
is called. In case the calls order is reversed, the _pendingOwner
will be deleted.
Not sure this is intended or not so leaving for sponsor review
CJ42 marked the issue as sponsor confirmed
trust1995 marked the issue as satisfactory
trust1995 marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2023-06-lukso/blob/main/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol#L176-L178
Vulnerability details
Bug Description
The
renounceOwnership()
function allows the owner of aLSP0ERC725Account
to renounce ownership through a two-step process. WhenrenounceOwnership()
is first called,_renounceOwnershipStartedAt
is set toblock.number
to indicate that the process has started:LSP14Ownable2Step.sol#L159-L167
When
renounceOwnership()
is called again, the owner is then set toaddress(0)
:LSP14Ownable2Step.sol#L176-L178
However, as
_pendingOwner
is only deleted in the first call torenounceOwnership()
, an owner could regain ownership of the account after the second call torenounceOwnership()
by doing the following:renounceOwnership()
for the first time to initiate the process.execute()
, perform a delegate call that overwrites_pendingOwner
to his own address.renounceOwnership()
again to set the owner toaddress(0)
.As
_pendingOwner
is still set to the owner's address, he can callacceptOwnership()
at anytime to regain ownership of the account.Impact
Even after the
renounceOwnership()
process is completed, an owner might still be able to regain ownership of an LSP0 account.This could potentially be dangerous if users assume that an LSP0 account will never be able to call restricted functions after ownership is renounced, as stated in the following comment:
For example, if a protocol's admin is set to a
LSP0ERC725Account
, the owner could gain the community's trust by renouncing ownership. After the protocol has gained a significant TVL, the owner could then regain ownership of the account and proceed to rug the protocol.Proof of Concept
The following Foundry test demonstrates how an owner can regain ownership of a
LSP0ERC725Account
afterrenounceOwnership()
has been called twice:Recommended Mitigation
Consider deleting
_pendingOwner
whenrenounceOwnership()
is called for a second time as well:LSP14Ownable2Step.sol#L176-L178
Assessed type
call/delegatecall