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

Basket might be unusable after initialization due to _initialSupply = 0 #159

Open
code423n4 opened this issue Dec 19, 2021 · 1 comment
Open
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

Handle

kenzo

Vulnerability details

A basket is not usable if totalSupply = 0.
When initializing a basket, the initial supply is passed as parameter, but the contract does not verify that that parameter is bigger than 0.

Impact

A basket may be unusable after deployment.

Proof of Concept

A basket should never have totalSupply = 0, as joinPool divides by totalSupply: (Code ref)

uint256 tokenAmount = balance(address(token)).mul(_amount.add(feeAmount)).div(totalSupply);

When the basket's ERC20 facet is initialized, it does not check whether the initialSupply parameter is bigger than 0. The mint function will also not revert.

So, the basket can be deployed with initialSupply = 0 and be unusable.

Note: it is not a part of the audit, but PieFactoryContract also does not check initialSupply.

Recommended Mitigation Steps

Add a check that requires initialSupply > 0.

@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 Dec 19, 2021
code423n4 added a commit that referenced this issue Dec 19, 2021
@loki-sama loki-sama added the disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) label Dec 29, 2021
@loki-sama loki-sama added sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons and removed sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels Jan 5, 2022
@0xleastwood
Copy link
Collaborator

I consider this a useful check, but it should be made low.

@0xleastwood 0xleastwood added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Jan 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Projects
None yet
Development

No branches or pull requests

3 participants