Skip to content
Business logic Audit finding Intermediate

Arctokenpurchase enabletoken can reset the amountsold to 0

The enableToken function in ArcTokenPurchase resets amountSold to zero when called again, even though it is meant only to configure a token sale. An admin re-enabling or updating sale parameters could therefore allow more tokens to be sold than the intended totalAmountForSale, causing an over-sale.

pks271 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

51122 sc low arctokenpurchase enabletoken can reset the amountsold to 0

Submitted on Jul 31st 2025 at 10:42:08 UTC by @pks271 for Attackathon | Plume Network

Description

ArcToken can be enabled to buy arc token by token contract admin through ArcTokenPurchase#enableToken function. But the related parameters can be reset again by calling ArcTokenPurchase#enableToken function including amountSold. This allows amountSold to be reset to 0 after some sales, which can lead to over-selling relative to the originally intended totalAmountForSale.

{% stepper %} {% step %}

Reproduction scenario (high level)

  • The token contract admin calls ArcTokenPurchase#enableToken to set totalAmountForSale = 1000.
  • Some tokens are purchased (e.g., amountSold = 700). {% endstep %}

{% step %}

Admin updates configuration

  • The token contract admin calls ArcTokenPurchase#enableToken again (for example to update tokenPrice).
  • This second call resets amountSold to 0 while remainingForSale remains based on totalAmountForSale. {% endstep %}

{% step %}

Over-sell occurs

  • After the reset, more tokens can be sold up to totalAmountForSale again (e.g., another 1000).
  • Total tokens sold becomes 1700 even though totalAmountForSale was originally 1000, causing over-sale and mismatch with underlying RWA. {% endstep %} {% endstepper %}

Impact

{% hint style="warning" %} Arc token can be sold out more than expected, which is unfair to earlier buyers and may result in insufficient RWA to deliver the promised assets. {% endhint %}

Recommendation

{% hint style="info" %} Do not allow amountSold to be reset to 0 when calling ArcTokenPurchase#enableToken. Ensure amountSold is preserved (or updated correctly) when the admin re-enables or updates sale parameters so that total accounting cannot be reset and over-selling cannot occur. {% endhint %}

Proof of Concept

This test reproduces the issue by enabling a sale, selling 700 tokens, refilling the contract, re-calling enableToken (which resets amountSold), and then selling 1000 tokens again — resulting in 1700 tokens sold despite totalAmountForSale being 1000.

{% code title="ArcTokenPurchase.t.sol" %}

Solidity
 function test_EnableToken_Overflow() public {
        // Mint additional tokens to owner to ensure sufficient balance
        token.mint(owner, 2000e18);

        uint256 initialTokensForSale = 1000e18;
        uint256 tokenPrice = 100e6; // 100 USDC per token

        // Replenish contract balance to 1000e18
        uint256 currentBalance = token.balanceOf(address(purchase));
        uint256 needed = initialTokensForSale - currentBalance;
        token.transfer(address(purchase), needed);
        
        console.log("Initial contract balance:", token.balanceOf(address(purchase)) / 1e18, "tokens");
        
        vm.prank(owner);
        purchase.enableToken(address(token), initialTokensForSale, tokenPrice);
        
        // Verify initial state
        ArcTokenPurchase.TokenInfo memory info1 = purchase.getTokenInfo(address(token));
        assertEq(info1.totalAmountForSale, initialTokensForSale);
        assertEq(info1.amountSold, 0);
        
        // Alice purchases 700 tokens
        uint256 alicePurchaseAmount = 700 * tokenPrice; // 700 * 100 USDC
        purchaseToken.mint(alice, alicePurchaseAmount);
        vm.prank(alice);
        purchaseToken.approve(address(purchase), alicePurchaseAmount);
        vm.prank(alice);
        purchase.buy(address(token), alicePurchaseAmount, 700e18);
        
        // Verify state after purchase
        ArcTokenPurchase.TokenInfo memory info2 = purchase.getTokenInfo(address(token));
        assertEq(info2.amountSold, 700e18);
        assertEq(token.balanceOf(alice), 700e18);
        
        console.log("After Alice purchase - Contract balance:", token.balanceOf(address(purchase)) / 1e18, "tokens");
        
        // Replenish contract balance to 1000e18 (critical step!)
        uint256 remainingBalance = token.balanceOf(address(purchase));
        uint256 additionalNeeded = initialTokensForSale - remainingBalance;
        token.transfer(address(purchase), additionalNeeded);
        
        console.log("After refill - Contract balance:", token.balanceOf(address(purchase)) / 1e18, "tokens");
        
        // Admin resets tokenPrice to 200 USDC (innocent or malicious)
        vm.prank(owner);
        purchase.enableToken(address(token), initialTokensForSale, tokenPrice*2);
        
        // Verify reset state
        ArcTokenPurchase.TokenInfo memory info3 = purchase.getTokenInfo(address(token));
        assertEq(info3.amountSold, 0, "BUG: amountSold was reset to 0!");
        assertEq(info3.totalAmountForSale, initialTokensForSale);
        
        // Bob can purchase 1000 tokens again
        uint256 bobPurchaseAmount = 1000 * tokenPrice*2;
        purchaseToken.mint(bob, bobPurchaseAmount);
        vm.prank(bob);
        purchaseToken.approve(address(purchase), bobPurchaseAmount);
        vm.prank(bob);
        purchase.buy(address(token), bobPurchaseAmount, 1000e18);
        
        // Verify final state
        assertEq(token.balanceOf(alice), 700e18);
        assertEq(token.balanceOf(bob), 1000e18);
        
        // Total sold 1700 tokens, but initially only set 1000
        uint256 totalSold = token.balanceOf(alice) + token.balanceOf(bob);
        assertEq(totalSold, 1700e18);
    }

{% endcode %}

The original report as published on Immunefi, by pks271. 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 enableToken function unconditionally overwrites the stored sale configuration, including amountSold, instead of preserving the existing sold count when updating parameters.

Impact

Arc tokens could be sold beyond the intended total, which is unfair to earlier buyers and may leave insufficient real-world assets to deliver the promised tokens.

What the attacker needed

Admin calls enableToken more than once; contract holds enough tokens to refill

The fix

The enableToken function should preserve the existing amountSold value when updating sale parameters, rather than resetting it to zero.

How it was found

  1. The admin calls enableToken to set totalAmountForSale to 1000.
  2. A buyer purchases 700 tokens, so amountSold becomes 700.
  3. The admin calls enableToken again, for example to update the token price.
  4. The second call resets amountSold to 0 while totalAmountForSale stays 1000.
  5. Another buyer purchases 1000 tokens, bringing total sold to 1700.

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 sale contract keeps a counter of how many tokens have been sold so far. The function that sets up the sale also wipes that counter back to zero every time it is called. If the admin calls it again to change the price, the contract forgets the earlier sales and lets buyers purchase the full amount again, so more tokens are sold than planned.

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 pks271

View all

9 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.