Assessment reports>Awaken Swap>High findings>The ,AssertContractInitialized, function should check ,Initialized
Category: Business Logic

The AssertContractInitialized function should check Initialized

High Severity
High Impact
Low Likelihood

Description

The helper function AssertContractInitialized is used to ensure that the contract is initialized prior to the execution of some actions:

private void AssertContractInitialized()
{
    Assert(State.Admin.Value != null, "Contract not initialized.");
}

However, instead of checking State.Initialized, it checks whether the admin is null. Although the admin is indeed null when the contract is uninitialized, after initialization, the admin can call ChangeOwner to set the admin property to null in order to renounce ownership.

Impact

If the admin renounces ownership by calling ChangeOwner to change the admin to null, then AssertContractInitialized will erroneously revert.

Recommendations

Compare Supply against TotalSupply instead of Issued.

Alternatively, if this is meant to be a cap on total issued quantity, the property should be renamed to TotalIssued and logic should be added to increase this constant once the limit is reached.

Remediation

This issue has been acknowledged by Awaken Finance, and a fix was implemented in commit 1eeef4bf.

Zellic © 2024Back to top ↑