Skip to content
Business logic Audit finding Intermediate

Admin fees are applied to NMX tokens during migration

During the migration of NXM tokens from the old arNXM contract to the new stNXM contract, the update modifier incorrectly calculates admin fees on the entire migrated balance because the staked amount is zero. This allows a malicious user or the owner to charge admin fees on all migrated NXM tokens, reducing users' balances.

dandan Follow with h2134 and merlin

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-11-stnxm-by-easedefi-judging/issues/444

Found by

dandan, h2134, merlin

Summary

The context of deployment of stNXM.sol:

1)Launch contract and initialize 2)Pause contract 3)Transfer over NFTs, NXM, and ownership from the old arNXM 4)Initialize External 5) Unpause

A malicious user or even the owner can charge admin fees on all NXM tokens from the old arNXM between steps 3 and 4.

Root Cause

The update modifier can be exploited by a malicious user or the owner to charge admin fees on NXM tokens migrating from arNXM to stNXM:

Solidity
if (balance > lastBalance && lastStaked <= staked) {
            adminFees += (balance - lastBalance) * adminPercent / DIVISOR;
        }

Internal Pre-conditions

  1. Launch the stNXM contract, initialize it, and pause it.
  2. Transfer NXM tokens from the old arNXM contract.

External Pre-conditions

None

Attack Path

  1. At this step, the stNXM contract is paused and NXM tokens are held on its balance.
  2. A malicious user or the owner calls resetTranches:
Solidity
 function resetTranches() public update { // update
        uint256 firstTranche = (block.timestamp / 91 days) - 1;

        for (uint256 i = 0; i < tokenIds.length; i++) {  // tokenIds isn't initialized
}}
  1. The resetTranches function called because it is not paused and it executes the update modifier.

balance > lastBalance is true because lastBalance = 0 and balance equals all tokens from arNXM. stakedNxm returns 0; lastStaked <= staked is true (0 <= 0)

Solidity
   modifier update() {
        uint256 nxmBalance = nxm.balanceOf(address(this));
        if (nxmBalance > 0) wNxm.wrap(nxmBalance);

        uint256 balance = wNxm.balanceOf(address(this));
        uint256 staked = stakedNxm(); // 0

        // amount of NXM from arNXM > 0 && 0 <= 0
        if (balance > lastBalance && lastStaked <= staked) {
            adminFees += (balance - lastBalance) * adminPercent / DIVISOR;
        }

        _;

        lastBalance = wNxm.balanceOf(address(this));
        lastStaked = stakedNxm(); 
    }
  1. The initializeExternals function is executed.

Impact

All migrated NXM tokens can be unfairly reduced by admin fees, causing users to lose part of their balance during the migration from arNXM to stNXM.

PoC

No response

Mitigation

Consider changing the update modifier:

Diff
- if (balance > lastBalance && lastStaked <= staked) {
+ if (balance > lastBalance && staked != 0 && lastStaked <= staked) {
            adminFees += (balance - lastBalance) * adminPercent / DIVISOR;
        }

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/EaseDeFi/stNXM-Contracts/commit/86decc1d35b729b342e3d5ceee29ba62becf35c0

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

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 update modifier checks if the balance increased and the staked amount did not decrease, but does not ensure that staking has actually occurred (staked > 0), so it applies admin fees to any balance increase, including migrations.

Impact

All migrated NXM tokens can be unfairly reduced by admin fees, causing users to lose part of their balance during the migration from arNXM to stNXM.

What the attacker needed

StNXM contract is paused; NXM tokens are held in stNXM; Attacker can call resetTranches

The fix

The update modifier should be changed to only apply admin fees when the staked amount is not zero, preventing fees on pure balance increases like migrations.

How it was found

  1. Launch the stNXM contract, initialize it, and pause it.
  2. Transfer NXM tokens from the old arNXM contract to stNXM.
  3. Call resetTranches, which executes the update modifier and calculates admin fees on the entire migrated balance.
  4. Initialize external contracts (initializeExternals).

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.

When tokens are moved from an old contract to a new one, the new contract has a rule that takes a small fee (admin fee) whenever the token balance increases. But during the move, the contract mistakenly thinks the increase is from staking rewards, so it takes a fee on the whole moved amount. This means users lose part of their tokens to fees they shouldn't have to pay.

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 dandan

View all

1 more disclosed report, best first.

More from stNXM by EaseDeFi

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.