Skip to content
Business logic Audit finding Intermediate

owner can hide a staked nft via removeTokenIdAtIndex and inflate shares using this to make profit

The owner can remove a staked NFT from the tokenIds array without withdrawing its stake, causing the vault's totalAssets to appear lower. The owner can then deposit to over-mint shares and later re-add the NFT to inflate totalAssets, redeeming shares at a higher price and diluting other holders.

0xKemah Follow with 0xxAristos, 5am and 24 others

Originally disclosed on Sherlock

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

Found by

0xKemah, 0xxAristos, 5am, AestheticBhai, Baccarat, Cybrid, Drynooo, IzuMan, PowPowPow, Solea, TianZun, Ziusz, asui, bbl4de, boredpukar, deadmanwalking, elolpuer, hanz, iamephraim, ivxylo, jayjoshix, peazzycole, slcoder, thimthor, tobi0x18, xKeywordx, zaida

Summary

The ability for the owner to remove a staked Nexus NFT from the tokenIds array without withdrawing its stake will cause manipulation and profit, as the owner can hide an NFT’s stake from stakedNxm()/totalAssets(), deposit while the vault appears under‑collateralized, then re‑expose the nft and redeem the over‑minted shares at a higher price

Root Cause

Solidity
function removeTokenIdAtIndex(uint256 _index) external onlyOwner {
    uint256 tokenId = tokenIds[_index];
    tokenIds[_index] = tokenIds[tokenIds.length - 1];
    tokenIds.pop();
    // remove mapping to pool
    delete tokenIdToPool[tokenId];
}

https://github.com/EaseDeFi/stNXM-Contracts/blob/b1431014cfadc4e5b65a9b93dfb52092313fef31/contracts/core/stNXM.sol#L723 when a token id is removed the akedNxm() computes the vault’s Nexus stake by looping only over tokenIds and, for each, using tokenIdToPool[token] plus tokenIdToTranches[token] to attribute a fraction of activeStake to the vault Removing an NFT from tokenIds causes all of its stake to disappear from stakedNxm() and thus from totalAssets() = stakedNxm() + unstakedNxm() - adminFees, while the NFT itself (and its Nexus stake) still belongs to the vault. Later, the owner can call stakeNxm(.., _requestTokenId = tokenId) to reuse the same NFT, at which point _stakeNxm will re‑insert the tokenId into tokenIds and tokenIdToPool, restoring that stake into stakedNxm() and totalAssets()

Internal Pre-conditions

na just owner needs to have funds

External Pre-conditions

na

Attack Path

to show this simple bug assume -

  • Real underlying: 10,000 wNXM in NFT k + 5,000 wNXM across other tracked NFTs = 15,000.​
  • tokenIds includes k, and tokenIdToPool[k] points to the correct Nexus pool.​
  • stakedNxm() correctly sums ≈15,000, so totalAssets() ≈ 15,000 and totalSupply() = 15,000 (1:1 price).​​

Owner hides the large NFT from accounting

  • Owner calls removeTokenIdAtIndex(i) where tokenIds[i] == k.​
  • Function swaps out H, pops the array, and deletes tokenIdToPool[k], but does not withdraw or modify the underlying stake in Nexus.​
  • stakedNxm() now loops only over the remaining tokenIds, so it sees only 5,000 wNXM; the 10,000 wNXM in NFT k is no longer included.​​
  • totalAssets_view drops to ≈5,000 while the real underlying remains 15,000.

Owner deposits while totalAssets() is artificially low

Owner calls deposit(10,000, owner).​​

ERC‑4626 computes minted shares with stale values: shares = depositAmount × totalSupply / totalAssets shares = 10,000 × 15,000 / 5,000 = 30,000 shares At the true totalAssets = 15,000, the owner should only receive 10,000 shares; they instead over‑mint by 20,000 shares (3x).​​ Owner re-adds the hidden NFT to accounting. Later, the owner calls stakeNxm(_smallAmount, poolForK, someTranche, k). _stakeNxm then calls pool.depositTo(..., _requestTokenId = k, address(this)), which returns the same tokenId = k. Because tokenIdToPool[k] was deleted earlier, _stakeNxm treats this as a new NFT: it pushes k back into tokenIds and sets tokenIdToPool[k] = poolForK. From this point on, stakedNxm() once again includes the full stake of NFT k, causing totalAssets() to jump to reflect ≈25,000 underlying (5,000 other + 10,000 hidden + 10,000 owner deposit, ignoring any small new stake). Owner redeems at the corrected higher price. With the full underlying now visible, the ERC-4626 share price is computed using totalAssets ≈ 25,000 and totalSupply = 45,000 (15,000 original + 30,000 owner). The owner then redeems a large portion (or all) of the 30,000 shares minted earlier, receiving significantly more wNXM than the 10,000 they originally deposited because the underlying NFT k is now fully counted in totalAssets(). The excess payout is effectively funded by diluting other stakers’ proportional claim over the true underlying value.

Impact

All stNXM holders other than the owner face loss as admin is basically stealing with this even if the owner is changed even doing this one time will make the protocol loss a huge chunk

PoC

No response

Mitigation

No response

Discussion

sherlock-admin2

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

The original report as published on Sherlock, by 0xKemah. 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 removeTokenIdAtIndex function deletes the tokenIdToPool mapping without withdrawing the underlying stake, so stakedNxm() no longer counts that NFT's stake even though the vault still owns it.

Impact

Other stNXM holders could lose value as the owner dilutes their claim by over-minting and redeeming shares at a higher price.

What the attacker needed

Owner privileges; owner has funds to deposit

The fix

The protocol team fixed this issue in a commit.

How it was found

  1. Owner calls removeTokenIdAtIndex to remove a large staked NFT from the tokenIds array.
  2. The vault's totalAssets drops because stakedNxm() no longer includes that NFT's stake.
  3. Owner calls deposit with a large amount, receiving more shares than fair due to the artificially low totalAssets.
  4. Owner calls stakeNxm with the same tokenId, which re-inserts it into tokenIds and restores its stake to totalAssets.
  5. Owner redeems the over-minted shares at the now higher share price, receiving more than deposited.

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 vault holds NFTs that represent staked cryptocurrency. The owner can temporarily remove one NFT from the vault's list of tracked NFTs, making the vault look like it has less money than it really does. Because the vault calculates share prices based on that list, the owner can deposit money to get more shares than deserved, then put the NFT back and cash out at a profit, taking value from other users.

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 0xKemah

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.