Skip to content
Business logic Write-up Advanced

Astar Network Integer Truncation Error Bug Fix Review

A vulnerability in the Astar Network node caused ERC-20 token transfer amounts to be truncated when converting from a 256-bit to a 128-bit integer, leading to discrepancies between the amount used in the smart contract and the amount processed by the node. An attacker could exploit this to drain liquidity pools by transferring a large amount that overflows to zero on the node side while still receiving tokens.

immunefi.com

Published on immunefi.com

On November 6, 2023, whitehat Farazsth98 of the Zellic team responsibly reported a vulnerability in the Astar Network node. Their finding was rewarded with a payout of $50,000 USD.

The author, on immunefi.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the node used a 128-bit integer to parse a 256-bit value from the EVM, causing truncation during type conversion.

Impact

An attacker could drain funds from vulnerable liquidity pools; in the demonstrated case, approximately $267,678 USD was at risk in one pool, though some projects like Uniswap forks were not vulnerable due to invariant checks.

What the attacker needed

A vulnerable smart contract on Astar Network; ability to call the exchange function

The fix

The vulnerable code was fixed by replacing the primitive data type with U256 from the sp_core library.

How it was found

  1. The attacker calls the exchange function of a vulnerable liquidity pool, transferring a number of tokens equal to uint256(type(uint128).max) + 1.
  2. The pool's exchange function invokes transferFrom and transfer calls with specific amounts.
  3. The Astar Network node intercepts these calls and processes them, but due to the type conversion error, the pool receives 0 tokens while the attacker receives the full amount.

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 write-up has not been written yet. The Original tab links to the source.

When computers store numbers, they have a fixed size. If you try to put a very large number into a smaller container, the extra digits are lost, like pouring a large bucket of water into a small cup. Here, the blockchain node used a smaller container for token amounts, so a huge transfer appeared as zero to the node, but the smart contract still recorded the full amount, letting an attacker get free tokens.

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.

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.