admin
state variable is being assigned a value without checking if the newAdmin
address is address(0)
.In Solidity, address(0)
is a special address that represents the zero address. Assigning address(0)
to a state variable can lead to unintended behavior, such as:
Reverting the contract's state to an invalid state
Allowing unauthorized access to the contract's functionality
Causing the contract to malfunction or crash
address(0)
is a special address that represents the zero address. Assigning address(0)
to a state variable can lead to unintended behavior, such as:Reverting the contract's state to an invalid state
Allowing unauthorized access to the contract's functionality
Causing the contract to malfunction or crash
Proof of Code is given below:
In this example, the Adminable
contract has a transferAdmin
function that allows the admin to be changed. However, there is no check to ensure that the newAdmin
address is not address(0)
.
The Attacker
contract has an attack
function that calls the transferAdmin
function with address(0)
as the newAdmin
address. This allows the attacker to set the admin to address(0)
, which can lead to unintended behavior.
Here's a breakdown of the code:
admin = newAdmin;
:
This line assigns the newAdmin
address to the admin
state variable.
However, there is no check to ensure that the newAdmin
address is not address(0)
.
adminable.transferAdmin(address(0));
:
This line calls the transferAdmin
function with address(0)
as the newAdmin
address.
This allows the attacker to set the admin to address(0)
, which can lead to unintended behavior.
newAdmin
address is not address(0)
before assigning it to the admin
state variable.Here's an example of how the code can be modified to add the check:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.