Skip to content
Smart contracts Audit finding Intermediate

Self transfer can lead to unlimited mint

The transfer function in nTokenAction.sol incorrectly handles self-transfers by making the amount negative and then converting it back to positive, which can lead to unlimited minting of tokens. An attacker could exploit this to mint an arbitrary number of tokens.

Omik Follow

Originally disclosed on Code4rena

Submitted by Omik, also found by gpersoon

The implementation of the transfer function in nTokenAction.sol is different from the usual erc20 token transfer function.

This happens because it counts the incentive that the user gets, but with a self-transfer, it can lead to unlimited mint. In L278, it makes the amount negative, but in L279, it returns the value to an amount that is not negative. So, in the L281-282, it finalizes a positive value, only because the negative value is changed to the positive value.

You can interact with this transfer function through nTokenERC20Proxy.sol.

Recommend adding (sender != recipient).

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

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

An attacker could mint an unlimited number of tokens, potentially devaluing the token and causing financial loss.

What the attacker needed

Ability to call transfer function

The fix

The transfer function should be fixed by adding a check that the sender and recipient are not the same address.

How it was found

  1. Interact with the transfer function through nTokenERC20Proxy.sol
  2. Perform a self-transfer (send tokens to yourself)
  3. Observe that the incentive calculation results in a positive amount, leading to unlimited mint

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 self-transfer is when you send tokens to yourself. The code that handles transfers mistakenly gives you extra tokens when you do this, and you can repeat it to create as many tokens as you want.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by Omik

View all

4 more disclosed reports, best first.

More from Notional contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.