Skip to content
Business logic Audit finding Intermediate

pushing same tranchId to the tokenIdToTranches will inflate stakedNxm accounting

The stNXM contract adds a tranche ID to a token's tranche list without checking for duplicates, so repeated staking with the same tranche ID inflates the computed stakedNxm and totalAssets. This can lead to incorrect minting and redemption amounts, and a malicious owner could exploit it to redeem at an inflated value.

0xAsen Follow with 0xDLG, 0xYjs and 34 others

Originally disclosed on Sherlock

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

Found by

0xAsen, 0xDLG, 0xYjs, 0xc0ffEE, 0xleo, AestheticBhai, Albert_Mei, Cybrid, Drynooo, MysteryAuditor, Orhukl, OxSath404, R4Y4N3, Solea, Vesko210, Wojack, Ziusz, algiz, asui, bbl4de, blockace, boredpukar, codexNature, coffiasd, cyberEth, elyas, frndz0ne, h2134, itsRavin, ivxylo, oxwhite, richardo, slcoder, theboiledcorn, thimthor, werulez99, zaida

Vulnerability Details

Tranche IDs are used to track accounting and expiry dates, and it is normal for stakers to use the same tranche ID to update their position.

When owner stakes NXM, the given _trancheId is added into tokenIdToTranches list.

Solidity
tokenIdToTranches[tokenId].push(_trancheId);

The problem is the function always adds the tranche ID to the list, without validating if it already exist. This leads to duplicate tranch IDs in the list.

Now, when stakedNxm is calculated it will return accumulation of assets for every tranche in the list;

Solidity
    uint256[] memory trancheIds = tokenIdToTranches[token];
Solidity
            for (uint256 j = 0; j < trancheIds.length; j++) {
                uint256 tranche = trancheIds[j];
                (,, uint256 stakeShares,) = IStakingPool(pool).getDeposit(token, tranche);

                if (tranche < currentTranche) {
                    (, uint256 amountAtExpiry, uint256 sharesAtExpiry) = IStakingPool(pool).getExpiredTranche(tranche);
                    // Pool has been properly expired here.
                    if (sharesAtExpiry > 0) assets += (amountAtExpiry * stakeShares) / sharesAtExpiry;
                    // The tranche ended but expirations have not been processed.
                    else assets += (activeStake * stakeShares) / stakeSharesSupply;
                } else {
                    assets += (activeStake * stakeShares) / stakeSharesSupply;

Since there are duplicate tranche IDs in the list assets amount calculated will be inflated.

And as a result totalAssets will be affected, which in turn breaks deposit/withdraw and other functionalities depending on totalAssets.

Note that there is a public resetTranches() function, but that is not forced and a user who can profit from it will likely not call it before redeeming. A redeem can also happen right after the inflation, since the resetTranches is not guaranteed.

Impact

higher totalAssets as a result of inflated stakedNxm. This will lead to users receiving incorrect minting & redeemig amounts.

This does not need the owner to be malicious, it will happen on normal conditions.

Well, even if there is a keeper bot to call resetTranches() in that case owner can intentionally be malicious and inflate the totalAssets and redeem right after duplicating the same tranche ID.

Owner malicious or not, Either way, this is an issue.

Recomended mitigation

push(add) only when the trancheId is not on the tokenIdToTranches list.

Discussion

sherlock-admin2

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

The original report as published on Sherlock, by 0xAsen. 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

Impact

totalAssets becomes inflated, leading to incorrect minting and redemption amounts; a malicious owner could exploit this to redeem at an inflated value, and the issue can occur under normal conditions.

What the attacker needed

Owner stakes NXM; same tranche ID used again

The fix

The staking function should only add the tranche ID to the list if it is not already present.

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 you stake tokens, the contract records which 'tranche' (a time period) your stake belongs to. If you stake again using the same tranche, the contract adds it again to a list, so later it counts your stake twice when calculating total assets. This can make the system think there is more money than there really is, leading to wrong amounts when people deposit or withdraw.

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

View all

17 more disclosed reports, 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.