Skip to content
Business logic Audit finding Beginner

Getmaxnumberoftokens returns wrong max number of tokens available to buy

The getMaxNumberOfTokens function reports an available token amount based on a stored total that is not reduced when unsold tokens are withdrawn. A buyer who trusts this figure and tries to purchase the full amount will have the buy call revert because the contract no longer holds enough tokens.

Oxgritty Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

51146 sc low getmaxnumberoftokens returns wrong max number of tokens available to buy

Submitted on Jul 31st 2025 at 15:10:10 UTC by @Oxgritty for Attackathon | Plume Network

Description

Brief / Intro

  • getMaxNumberOfTokens is used to know the quantity of tokens available to buy.
  • It returns a wrong amount because totalAmountForSale is not updated when withdrawUnsoldArcTokens is used to withdraw unsold ARC tokens.

Vulnerability Details

  • getMaxNumberOfTokens relies on info.totalAmountForSale to compute the available balance.
  • withdrawUnsoldArcTokens withdraws ARC tokens but does not update info.totalAmountForSale.
  • As a result, getMaxNumberOfTokens can return an amount greater than the actual token balance held by the contract.

Impact Details

  • A buyer calling getMaxNumberOfTokens may see an inflated available amount.
  • If the buyer attempts to purchase that inflated amount via buy, the buy call will revert due to ContractBalanceInsufficient.

References

  1. getMaxNumberOfTokens function:
    https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/arc/src/ArcTokenPurchase.sol#L359
  2. withdrawUnsoldArcTokens function:
    https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/arc/src/ArcTokenPurchase.sol#L439
  3. buy function revert due to insufficient balance:
    https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/arc/src/ArcTokenPurchase.sol#L263

Proof of Concept

{% stepper %} {% step %}

Setup

Token Admin calls enableToken to register a token for sale with totalAmountForSale = 500e18. {% endstep %}

{% step %}

Withdraw unsold tokens

Token Admin calls withdrawUnsoldArcTokens to withdraw 50e18 tokens. (Contract token balance is now 450e18, but info.totalAmountForSale remains 500e18.) {% endstep %}

{% step %}

Buyer queries available tokens

Buyer calls getMaxNumberOfTokens.
The function returns 500e18 (based on info.totalAmountForSale), which is higher than the actual balance. {% endstep %}

{% step %}

Buy attempt fails

Buyer calls buy with amount 500e18.
The buy call reverts due to ContractBalanceInsufficient. {% endstep %} {% endstepper %}

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

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

Root cause

Likely the withdrawUnsoldArcTokens function reduces the contract's token balance without also reducing the stored totalAmountForSale value that getMaxNumberOfTokens relies on.

Impact

A buyer may see an inflated available amount and have their purchase revert, but no funds are lost and the text does not claim any theft or bypass.

What the attacker needed

Token admin has enabled a token sale; Token admin withdraws some unsold tokens; Buyer relies on getMaxNumberOfTokens

How it was found

  1. Token Admin registers a token for sale with a total amount of 500e18.
  2. Token Admin withdraws 50e18 unsold tokens, leaving a contract balance of 450e18 while the stored total stays at 500e18.
  3. Buyer calls getMaxNumberOfTokens and receives 500e18, which is higher than the real balance.
  4. Buyer calls buy with 500e18 and the transaction reverts with ContractBalanceInsufficient.

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 smart contract keeps a record of how many tokens it has for sale. When the owner takes some unsold tokens out, that record is not updated, so the contract still advertises the old, larger number. Anyone who tries to buy that advertised amount will fail because the tokens are no longer there.

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 Oxgritty

View all

5 more disclosed reports, best first.

More from Plume Network

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.