Skip to content

[GrantShares] GBA-02 onlyOwner Enforcement Hinders Role Separation #72

Open
@OT-kraftchain

Description

@OT-kraftchain

During the execution of the deploy method, a check of the onlyOwner is performed, and this verifications result unnecessary since the method can only be executed during the contract's deployment, so the owner will never be established, thus there is no need for an identity verification.

This verification not only incurs additional gas costs but also forces the Owner to being the deployer, preventing it from being a cold wallet, which is not a recommended practice.

Recommendations
• Remove the call to the onlyOwner() method during the deploy process, allowing the owner to be set to be different from the address performing the deployment.

Source Code References

public static void deploy(Object data, boolean update) {
if (!update) {
Storage.put(context, VERSION_KEY, 1);
// Initialize the contract.
DeployData deployData = (DeployData) data;
Hash160 initialOwner = deployData.initialOwner;
if (initialOwner == null || !Hash160.isValid(initialOwner) || initialOwner.isZero()) {
abort("invalid initial owner");
}
Storage.put(context, OWNER_KEY, initialOwner);
onlyOwner();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions