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.
- 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
- Report ID: #51391
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/immunefi-team/attackathon-plume-network/blob/main/arc/src/ArcTokenPurchase.sol
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
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:
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
enableTokenis called again, the contract permanently loses the record of those 600 sales - False Reporting:
getTokenInfo()returnsamountSold: 0instead 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
Proof of Concept
{% stepper %} {% step %}
Step: Initial Setup
enableToken(tokenAddress, 1000e18, 10e6); // 1000 tokens at $10
// State: {amountSold: 0, totalAmountForSale: 1000e18}
{% endstep %}
{% step %}
Step: Sales Occur
// Users buy 600 tokens through multiple transactions
// State: {amountSold: 600e18, totalAmountForSale: 1000e18}
{% endstep %}
{% step %}
Step: Admin Updates Parameters
// Admin wants to update price or adjust remaining supply
enableToken(tokenAddress, 400e18, 15e6); // 400 tokens at $15
// State: {amountSold: 0, totalAmountForSale: 400e18}
Result:
// 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 %}
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
- Call enableToken to set up a token with initial parameters.
- Users buy tokens, increasing amountSold.
- Admin calls enableToken again to update parameters.
- 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.