Skip to content
Business logic Audit finding Beginner

Enabletoken function overwrites amountsold to zero causing permanent loss of sales history

The enableToken function resets the amountSold field to zero every time it is called, erasing the record of previous token sales. An attacker (or admin) could call this function to permanently lose sales history, causing the contract to report incorrect sales data.

vivekd Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

51391 sc low enabletoken function overwrites amountsold to zero causing permanent loss of sales history

Submitted on Aug 2nd 2025 at 10:47:27 UTC by @vivekd for Attackathon | Plume Network

Description

Brief/Intro

The enableToken function unconditionally resets the amountSold field to zero when called, permanently erasing all records of previous token sales.

This data loss prevents the contract from delivering accurate sales tracking, which is a core functionality of any token sale contract.

Vulnerability Details

The vulnerability occurs in the enableToken function:

Solidity
ps.tokenInfo[_tokenContract] = TokenInfo({ 
    isEnabled: true, 
    tokenPrice: _tokenPrice, 
    totalAmountForSale: _numberOfTokens, 
    amountSold: 0  // ← Always resets to 0, erasing sales history
});

The function completely overwrites the TokenInfo struct without preserving the existing amountSold value. This means:

  • Any record of previous sales is permanently lost
  • The contract "forgets" how many tokens were sold
  • There's no way to recover this data once overwritten

Impact Details

The contract fails to maintain accurate sales records:

  • Permanent Data Loss: If 600 tokens were sold and enableToken is called again, the contract permanently loses the record of those 600 sales
  • False Reporting: getTokenInfo() returns amountSold: 0 instead of the actual amount, making the contract unreliable for:
    • Revenue tracking
    • Sales analytics
    • Financial reconciliation
    • Audit trails
  • Broken Invariants: The fundamental accounting equation is violated:
    • Actual tokens distributed: 600
    • Contract's record: 0
    • This discrepancy cannot be corrected

References

https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/arc/src/ArcTokenPurchase.sol#L136-L178

Proof of Concept

{% stepper %} {% step %}

Step: Initial Setup

Solidity
enableToken(tokenAddress, 1000e18, 10e6); // 1000 tokens at $10
// State: {amountSold: 0, totalAmountForSale: 1000e18}

{% endstep %}

{% step %}

Step: Sales Occur

Solidity
// Users buy 600 tokens through multiple transactions
// State: {amountSold: 600e18, totalAmountForSale: 1000e18}

{% endstep %}

{% step %}

Step: Admin Updates Parameters

Solidity
// Admin wants to update price or adjust remaining supply
enableToken(tokenAddress, 400e18, 15e6); // 400 tokens at $15
// State: {amountSold: 0, totalAmountForSale: 400e18}

Result:

Solidity
// Before: amountSold = 600e18 (correct)
// After: amountSold = 0 (data lost)

The contract now incorrectly reports that zero tokens have been sold, despite 600 tokens actually being distributed. This permanent loss of sales data causes the contract to fail in its core purpose of tracking token sales accurately. {% endstep %} {% endstepper %}

The original report as published on Immunefi, by vivekd. 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

The enableToken function overwrites the entire TokenInfo struct without preserving the existing amountSold value.

Impact

The contract permanently loses sales history, leading to false reporting and broken accounting invariants, but no direct loss of funds.

What the attacker needed

Admin calls enableToken again

How it was found

  1. Call enableToken to set up a token with initial parameters.
  2. Users buy tokens, increasing amountSold.
  3. Admin calls enableToken again to update parameters.
  4. The amountSold is reset to zero, losing the sales history.

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.

This smart contract keeps track of how many tokens have been sold. But a function that is supposed to just enable a token also wipes out that sales count, setting it back to zero. So if someone calls it again, the contract forgets all previous sales, which can mess up reporting and accounting.

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 vivekd

View all

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