Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect initial mint will break the contract #125

Closed
code423n4 opened this issue May 20, 2022 · 3 comments
Closed

Incorrect initial mint will break the contract #125

code423n4 opened this issue May 20, 2022 · 3 comments
Labels
bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate This issue or pull request already exists G (Gas Optimization) resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-05-aura/blob/main/contracts/Aura.sol#L71

Vulnerability details

Impact

It was observed that if initial mint via init function becomes < EMISSIONS_MAX_SUPPLY then mint function will always fail due to totalSupply()<EMISSIONS_MAX_SUPPLY (failing Aura.sol#L101)

Proof of Concept

  1. Owner calls the init function and provide amount as 100
  2. totalSupply becomes 100
  3. Operator now calls the mint function
  4. mint function fails since totalSupply()<EMISSIONS_MAX_SUPPLY
uint256 emissionsMinted = totalSupply() - EMISSIONS_MAX_SUPPLY - minterMinted;

Recommended Mitigation Steps

The init function should call _mint function with amount as EMISSIONS_MAX_SUPPLY or more.

uint256 public constant EMISSIONS_MAX_SUPPLY = 5e25; // 50m
uint256 public constant INIT_SUPPLY = 5e25; // 50m

function init(
        address _to,
        address _minter
    ) external {
        ...

        _mint(_to, INIT_SUPPLY);
        ...
    }

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels May 20, 2022
code423n4 added a commit that referenced this issue May 20, 2022
@0xMaharishi
Copy link

Valid report, however given that the deploySystem script always runs with > 5e25, there is no immediate cause for concern. To make the contract more robust we can add some protections. Duplicate of #97 although i think this issue is much better

@0xMaharishi 0xMaharishi added disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels May 26, 2022
@0xMaharishi 0xMaharishi added the resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) label May 30, 2022
@dmvt
Copy link
Collaborator

dmvt commented Jun 23, 2022

As with #97, this is a gas issue. The full impact of this happening would be that the team would need to redeploy the contract.

@dmvt dmvt added G (Gas Optimization) duplicate This issue or pull request already exists and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Jun 23, 2022
@dmvt
Copy link
Collaborator

dmvt commented Jun 25, 2022

Grouping this with the warden’s gas report, #129

@dmvt dmvt closed this as completed Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate This issue or pull request already exists G (Gas Optimization) resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

3 participants