Skip to content
Business logic Audit finding Intermediate

totalSupply may exceed LibBasketStorage.basketStorage().maxCap

The joinPool function checks the maximum cap using only the base amount, ignoring the fee that is also minted to the fee beneficiary. An attacker could mint tokens beyond the intended maxCap by joining the pool when fees are enabled.

Czar102 Follow

Originally disclosed on Code4rena

Submitted by Czar102, also found by gpersoon, gzeon, kenzo, and WatchPug

Impact

Total supply of the token may exceed the maxCap introduced. This can happen when a user wants to join the pool. The check in BasketFacet::joinPool(...) includes only the base amount, without fee. Thus, if fee is on and someone will want to create as many tokens as possible, the totalSupply + _amount will be set to maxCap. The call will succeed, but new tokens were also minted as the fee for bs.feeBeneficiary if bs.entryFee and bs.entryFeeBeneficiaryShare are nonzero. Thus, the number of tokens may exceed maxCap.

Recommended Mitigation Steps

Consider calculating feeAmount and feeBeneficiaryShare before the require(...) statement and check totalSupply.add(_amount).add(feeBanficiaryShare) <= this.getCap().

loki-sama (Amun) acknowledged

The original report as published on Code4rena, by Czar102. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

The total supply of the token could exceed the intended maxCap, potentially diluting value or breaking assumptions.

What the attacker needed

EntryFee and entryFeeBeneficiaryShare are nonzero

The fix

The fee amount and beneficiary share should be calculated before the cap check, and the check should include them.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A token has a maximum supply limit. When someone adds funds to the pool, the contract checks that the new total won't exceed this limit. However, the check forgets that a fee is also minted as new tokens, so the actual total can go over the limit.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Czar102

View all

12 more disclosed reports, best first.

More from Amun contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.