Skip to content
Business logic Audit finding Beginner

GetMaxNumberOfTokens() returns wrong value when ArcTokens are withdrawn

The getMaxNumberOfTokens() function computes available tokens as totalAmountForSale minus amountSold, ignoring tokens that were withdrawn. After a withdrawal it overstates how many tokens can still be bought, so callers relying on it get a wrong figure.

Plume Network

Originally disclosed on Immunefi

50415 sc low getmaxnumberoftokens returns wrong value when arctokens are withdrawn

Submitted on Jul 24th 2025 at 11:34:57 UTC by @KlosMitSoss for Attackathon | Plume Network

Description

Brief/Intro
The getMaxNumberOfTokens() function returns the maximum number of ArcTokens that can be bought. However, this function returns incorrect values when ArcTokens have been withdrawn.

Vulnerability Details

getMaxNumberOfTokens() returns the difference between totalAmountForSale and amountSold. This does not account for ArcTokens that were withdrawn. When tokens are withdrawn, they are no longer available for purchase, but the function continues to count them as available, leading to an overestimation of purchasable tokens.

The function should subtract withdrawn tokens from the available supply to provide accurate information about how many tokens can actually be purchased.

Impact Details

getMaxNumberOfTokens() returns wrong values.

Proof of Concept

{% stepper %} {% step %}

Step

Call ArcTokenPurchase::enableToken() to enable 100e18 ArcTokens for sale.

Reference: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/arc/src/ArcTokenPurchase.sol#L142-L178 {% endstep %}

{% step %}

Step

Call ArcTokenPurchase::withdrawUnsoldArcTokens() to withdraw 10e18 ArcTokens.

Reference: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/arc/src/ArcTokenPurchase.sol#L439-L461 {% endstep %}

{% step %}

Step

Observe that ArcTokenPurchase::getMaxNumberOfTokens() still returns 100e18 even though only 90e18 are actually available for sale.

Reference: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/arc/src/ArcTokenPurchase.sol#L359-L364 {% endstep %} {% endstepper %}

References

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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

Plume Network's ARC sale contract, ArcTokenPurchase.sol, exposes a view function, getMaxNumberOfTokens(), that is meant to tell callers the maximum number of ArcTokens that can still be bought. The report targets that single function and the accounting it relies on.

Internally the function computes the difference between totalAmountForSale and amountSold. That works as long as every token that was put up for sale is still sitting in the contract. The contract also lets the owner pull unsold tokens back out through withdrawUnsoldArcTokens(), and that is where the accounting breaks: withdrawn tokens leave the contract but are never subtracted from the figure the view function reports.

The finding was filed against the Attackathon | Plume Network program on Immunefi as report #50415, severity Low, under the impact category "Contract fails to deliver promised returns, but doesn't lose value".

Setup

The report does not describe any accounts, roles, tooling or versions. The only preconditions it relies on are the three contract functions involved, all in arc/src/ArcTokenPurchase.sol:

Function Purpose in the report
enableToken() Puts a quantity of ArcTokens up for sale
withdrawUnsoldArcTokens() Removes unsold ArcTokens from the sale
getMaxNumberOfTokens() Reports how many tokens can still be bought

The researcher references the file at commit [redacted], with enableToken() at lines 142 to 178, getMaxNumberOfTokens() at lines 359 to 364 and withdrawUnsoldArcTokens() at lines 439 to 461.

Finding it

The researcher compared what getMaxNumberOfTokens() reports with what the contract can actually deliver. The function returns totalAmountForSale - amountSold, which is a correct answer only while the full sale allocation is still held by the contract. Once tokens are withdrawn, the contract holds less than totalAmountForSale, yet the subtraction still uses the original figure. The result is an overestimate: the function keeps counting withdrawn tokens as purchasable.

Exploitation

The proof of concept is a three-step sequence that makes the discrepancy visible. It is a demonstration of incorrect state reporting, not an attack that moves funds.

Step 1: enable tokens for sale

Call ArcTokenPurchase::enableToken() to enable 100e18 ArcTokens for sale.

Text
ArcTokenPurchase::enableToken()

The report states that 100e18 ArcTokens become available for sale.

Step 2: withdraw unsold tokens

Call ArcTokenPurchase::withdrawUnsoldArcTokens() to withdraw 10e18 ArcTokens.

Text
ArcTokenPurchase::withdrawUnsoldArcTokens()

After this call only 90e18 tokens are actually available for sale, because 10e18 have been withdrawn.

Step 3: read the reported maximum

Observe that ArcTokenPurchase::getMaxNumberOfTokens() still returns 100e18 even though only 90e18 are actually available for sale.

Text
ArcTokenPurchase::getMaxNumberOfTokens()

The view function has no knowledge of the withdrawal, so its output is 10e18 too high.

Root cause

getMaxNumberOfTokens() derives its answer from totalAmountForSale and amountSold only. withdrawUnsoldArcTokens() removes tokens from the sale, but the view function still counts them as available. The report states the fix directly: the function should subtract withdrawn tokens from the available supply so that it reports how many tokens can actually be purchased. Whether the contract keeps such a record at all is not described in the report.

Impact

The impact is limited to incorrect information: getMaxNumberOfTokens() returns wrong values. The report classifies this as "Contract fails to deliver promised returns, but doesn't lose value", so no funds are described as being at risk. The report states only that getMaxNumberOfTokens() returns wrong values.

Fix

The report does not say whether a fix was applied. The change it calls for is to make getMaxNumberOfTokens() account for withdrawn tokens, subtracting them from the available supply so the returned maximum matches what can actually be bought.

Variants to test

  • Other "max purchasable" or "remaining supply" views. Look for any view function that computes availability from a stored total minus a sold counter. A positive result is a view whose output stays unchanged after an owner withdrawal or rescue function removes part of the inventory.
  • Rescue and sweep functions. Any function that moves sale inventory out of the contract (unsold token withdrawal, emergency rescue, migration) is a candidate. A positive result is inventory leaving the contract without a corresponding adjustment to the variable the view function reads.
  • Cached totals versus live balances. Where a contract stores a sale total at configuration time and later compares it against balanceOf(address(this)), check whether the two can diverge. A positive result is a stored total that no longer matches the contract's balance while the view still reports the stored total.
  • Multiple enable or top-up paths. If tokens can be added to a sale more than once, check that each path updates the same variable the view function uses. A positive result is a view that under- or over-reports after a second configuration call.

Hunting notes

This class of bug hides in accounting views that are one subtraction away from the truth: total - sold, cap - minted, supply - claimed. The signal during review is a contract that has both a configuration function setting the total and a withdrawal or rescue function that can reduce the inventory, with no shared variable tying the two together. Reading the view function in isolation is not enough; the question to ask is which state-changing functions can move tokens out while leaving the total untouched.

Proving it is cheap: a short sequence of calls that sets up a sale, removes part of it, and then reads the view is enough to show the mismatch, as the three steps above do. The report keeps the demonstration to that sequence and states the impact plainly as wrong return values, which matches the Low severity and the "fails to deliver promised returns, but doesn't lose value" impact category.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

What happened, in plain words

Plume Network runs a sale of a digital token called ArcToken. A smart contract, ArcTokenPurchase.sol, handles that sale. A smart contract is a small program that lives on a blockchain: it runs by itself, follows rules written into its code, and anyone can call the functions it exposes. Think of it as a vending machine that nobody can open and reprogram, only press buttons on.

One of the buttons on this machine is a "view" function called getMaxNumberOfTokens(). A view function is a read-only question: you ask the contract something and it answers, without changing anything. This particular question is meant to answer: how many ArcTokens can still be bought right now?

The contract also has a button that lets the owner take unsold tokens back out of the sale, called withdrawUnsoldArcTokens(). The problem is that after tokens are taken out, the answer to the question stays the same. The contract keeps counting the withdrawn tokens as if they were still for sale. So it says more tokens are available than really are.

The researcher filed this as report #50415 on the Attackathon | Plume Network program on Immunefi, with severity Low, under the impact category "Contract fails to deliver promised returns, but doesn't lose value". In plain terms: the contract gives out wrong information, but nobody's money is described as being stolen or lost.

The pieces involved

The report does not describe any accounts, roles, tools or software versions. The only things it relies on are three functions, all in the file arc/src/ArcTokenPurchase.sol:

Function What it does in this report
enableToken() Puts a quantity of ArcTokens up for sale
withdrawUnsoldArcTokens() Takes unsold ArcTokens back out of the sale
getMaxNumberOfTokens() Answers how many tokens can still be bought

The researcher points at the file at a specific commit, [redacted]. A commit is a saved snapshot of a code repository, like a numbered version of a document, so the exact lines can be found again later. In that snapshot, enableToken() is at lines 142 to 178, getMaxNumberOfTokens() at lines 359 to 364, and withdrawUnsoldArcTokens() at lines 439 to 461.

How the bug was found

The researcher compared two things: what the contract says is available, and what it can actually deliver. That is a common way to spot this kind of bug. You do not need to break anything; you just ask the contract a question and check whether the answer matches reality.

Inside, getMaxNumberOfTokens() works out its answer as totalAmountForSale minus amountSold. totalAmountForSale is a stored number recording how many tokens were put up for sale. amountSold is a stored number recording how many have been bought so far. Subtracting one from the other gives the remaining amount, which is correct as long as every token that was put up for sale is still sitting in the contract.

But the contract also lets the owner pull unsold tokens back out. When that happens, tokens physically leave the contract, yet the stored totalAmountForSale is not reduced. The subtraction still uses the original, larger figure. So the answer is too high: the function keeps counting withdrawn tokens as purchasable.

Walking through the proof

The proof of concept is a three-step sequence that makes the mismatch visible. It is a demonstration of wrong reporting, not an attack that moves funds. Each step is a call to one function of the contract.

Step 1: put tokens up for sale

Call ArcTokenPurchase::enableToken() to enable 100e18 ArcTokens for sale.

Text
ArcTokenPurchase::enableToken()

This line names the contract (ArcTokenPurchase) and the function to call on it (enableToken()). The :: is just a separator meaning "the function inside this contract". The report does not show any arguments, but it states the effect: 100e18 ArcTokens become available for sale. The notation 100e18 means the number 100 followed by 18 zeros, which is how token amounts are usually written in this world, because tokens are often split into very small units. The report states the effect: 100e18 ArcTokens become available for sale.

Step 2: take some of them back out

Call ArcTokenPurchase::withdrawUnsoldArcTokens() to withdraw 10e18 ArcTokens.

Text
ArcTokenPurchase::withdrawUnsoldArcTokens()

Again, the line names the contract and the function. The report states the effect: 10e18 ArcTokens leave the sale. After this call only 90e18 tokens are actually available for sale, because 10e18 have been withdrawn. This is the step that creates the gap between what is stored and what is real.

Step 3: ask the question again

Observe that ArcTokenPurchase::getMaxNumberOfTokens() still returns 100e18 even though only 90e18 are actually available for sale.

Text
ArcTokenPurchase::getMaxNumberOfTokens()

This line calls the read-only question. The report states the result: it answers 100e18, the original figure, even though only 90e18 remain. The function has no knowledge of the withdrawal, so its answer is 10e18 too high.

Why it happens

getMaxNumberOfTokens() builds its answer from totalAmountForSale and amountSold only. withdrawUnsoldArcTokens() removes tokens from the sale, but the view function still counts them as available. The report states the fix directly: the function should subtract withdrawn tokens from the available supply so that it reports how many tokens can actually be purchased. Whether the contract keeps such a record at all is not described in the report.

What the impact is

The impact is limited to incorrect information: getMaxNumberOfTokens() returns wrong values. The report classifies this as "Contract fails to deliver promised returns, but doesn't lose value", so no funds are described as being at risk. The report states only that getMaxNumberOfTokens() returns wrong values.

The fix

The change it calls for is to make getMaxNumberOfTokens() account for withdrawn tokens, subtracting them from the available supply so the returned maximum matches what can actually be bought.

Similar places to look

  • Other "max purchasable" or "remaining supply" views. Look for any read-only function that computes availability from a stored total minus a sold counter. A positive result is a view whose output stays unchanged after an owner withdrawal or rescue function removes part of the inventory.
  • Rescue and sweep functions. Any function that moves sale inventory out of the contract (unsold token withdrawal, emergency rescue, migration) is a candidate. A positive result is inventory leaving the contract without a corresponding adjustment to the variable the view function reads.
  • Cached totals versus live balances. Where a contract stores a sale total at configuration time and later compares it against balanceOf(address(this)), check whether the two can diverge. A positive result is a stored total that no longer matches the contract's balance while the view still reports the stored total.
  • Multiple enable or top-up paths. If tokens can be added to a sale more than once, check that each path updates the same variable the view function uses. A positive result is a view that under- or over-reports after a second configuration call.

Notes for anyone hunting this class of bug

This kind of bug hides in accounting views that are one subtraction away from the truth: total - sold, cap - minted, supply - claimed. The signal during review is a contract that has both a configuration function setting the total and a withdrawal or rescue function that can reduce the inventory, with no shared variable tying the two together. Reading the view function in isolation is not enough; the question to ask is which state-changing functions can move tokens out while leaving the total untouched.

Proving it is cheap: a short sequence of calls that sets up a sale, removes part of it, and then reads the view is enough to show the mismatch, as the three steps above do. The report keeps the demonstration to that sequence and states the impact plainly as wrong return values, which matches the Low severity and the "fails to deliver promised returns, but doesn't lose value" impact category.

Glossary

  • Smart contract: a program that runs on a blockchain, follows rules written into its code, and exposes functions anyone can call.
  • Blockchain: a shared, tamper-resistant record of transactions kept by many computers at once.
  • ArcToken: the digital token being sold in this report.
  • Plume Network: the project whose sale contract is described here.
  • Immunefi: a platform where security researchers report bugs in software and are rewarded for valid findings.
  • Attackathon: the name of the bug bounty program on Immunefi under which this report was filed.
  • Bug bounty: a scheme where a project pays people for reporting security problems to it.
  • Severity: a label for how serious a bug is; here it is Low.
  • View function: a read-only function that answers a question without changing any stored data.
  • Function: a named action a contract can perform, called by name.
  • Call: asking a contract to run one of its functions.
  • enableToken(): the function that puts a quantity of ArcTokens up for sale.
  • withdrawUnsoldArcTokens(): the function that takes unsold ArcTokens back out of the sale.
  • getMaxNumberOfTokens(): the read-only function that reports how many tokens can still be bought.
  • totalAmountForSale: a stored number recording how many tokens were put up for sale.
  • amountSold: a stored number recording how many tokens have been bought so far.
  • Commit: a saved snapshot of a code repository, identified by a long string of characters, so exact lines can be found again.
  • Proof of concept (PoC): a short sequence of steps that demonstrates a bug actually happens.
  • 100e18 / 10e18: shorthand for 100 and 10 followed by 18 zeros, a common way to write token amounts that are split into very small units.
  • State: the data a contract stores and updates as its functions are called.
  • State-changing function: a function that alters stored data, as opposed to a read-only view.
  • balanceOf(address(this)): a standard way to ask a token contract how many tokens a particular address holds; address(this) means the contract itself.
  • Rescue / sweep function: a function that moves tokens out of a contract, often for emergencies or cleanup.
  • Integrator: another project or service that reads or uses this contract's data.
  • Impact category: the label a bounty program uses to describe the kind of harm a bug causes; here "Contract fails to deliver promised returns, but doesn't lose value".
  • Root cause: the underlying reason a bug exists in the code.

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.