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.
- 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
- Report ID: #51146
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/immunefi-team/attackathon-plume-network/blob/main/arc/src/ArcTokenPurchase.sol
Description
Brief / Intro
getMaxNumberOfTokensis used to know the quantity of tokens available to buy.- It returns a wrong amount because
totalAmountForSaleis not updated whenwithdrawUnsoldArcTokensis used to withdraw unsold ARC tokens.
Vulnerability Details
getMaxNumberOfTokensrelies oninfo.totalAmountForSaleto compute the available balance.withdrawUnsoldArcTokenswithdraws ARC tokens but does not updateinfo.totalAmountForSale.- As a result,
getMaxNumberOfTokenscan return an amount greater than the actual token balance held by the contract.
Impact Details
- A buyer calling
getMaxNumberOfTokensmay see an inflated available amount. - If the buyer attempts to purchase that inflated amount via
buy, thebuycall will revert due toContractBalanceInsufficient.
References
getMaxNumberOfTokensfunction:
https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/arc/src/ArcTokenPurchase.sol#L359withdrawUnsoldArcTokensfunction:
https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/arc/src/ArcTokenPurchase.sol#L439buyfunction 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 %}
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
- Token Admin registers a token for sale with a total amount of 500e18.
- Token Admin withdraws 50e18 unsold tokens, leaving a contract balance of 450e18 while the stored total stays at 500e18.
- Buyer calls getMaxNumberOfTokens and receives 500e18, which is higher than the real balance.
- 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.