# Astar Network Integer Truncation Error Bugfix Review

Astar node truncated ERC-20 transfer amounts from uint256 to uint128, letting an attacker mint tokens in a DEX pool and drain ~$267k.

- Payout: $50,000
- Severity: critical
- Program: Astar Network
- Credited: Farazsth98
- Disclosed: 2024-01-11
- Write-up quality: 8/10
- Original: https://immunefi.com/blog/bug-fix-reviews/astar-network-integer-truncation-error-bugfix-review/
- Library page: https://bugbountylibrary.com/r/blog%3Aimmunefi-com-blog-bug-fix-reviews-astar-network-integer-truncation-error-bugfix-review
- Tags: domain:web3 impact:funds-loss kind:bounty platform:blog platform:immunefi sev:critical tech:evm tech:rust technique:chained technique:source-review vuln:business-logic vuln:precision-loss

**Target:** Substrate node ERC-20 transfer bridge between EVM and WASM runtimes
**Root cause:** The cross-VM ERC-20 transfer component parsed EVM uint256 amounts into a Rust primitive uint128, silently dropping high bits so the destination runtime received a different value than the source.
**Steps:**
1. Identify the node component bridging ERC-20 transfer amounts between EVM and WASM execution environments.
2. Call the DEX exchange function with amount `uint256(type(uint128).max) + 1` = `340282366920938463463374607431768211456`.
3. Pool invokes `transferFrom(attacker, pool, 340282366920938463463374607431768211456)` and `transfer(attacker, 291340481688343319786137)`.
4. Node truncates the transferFrom amount to 0 on the destination side while the transfer out of 291340481688343319786137 tokens is honored.
5. Attacker receives pool tokens without depositing any, draining the Kagla Finance pool (~$267,678 at risk).
**How found:** Researcher noticed the node used fixed-size Rust primitive types (uint128) to parse data originating from the EVM's larger uint256, hypothesizing that cross-VM amount conversion would silently truncate; then checked which DEX contracts lacked post-swap invariant checks (Uniswap forks were safe) and built a PoC against Kagla Finance.
**Exploitation:** Attacker calls the vulnerable DEX exchange function with an amount equal to 2^128, which overflows the uint128 conversion in the Astar node's cross-VM transfer handler; the pool records a zero deposit while the attacker's withdrawal of ~2.9e23 tokens succeeds, draining liquidity.
**Insight:** When a chain bridges two VMs with different integer widths, audit every cross-VM amount/balance conversion for silent truncation, and target DEXes lacking post-swap invariant checks since those won't catch the mismatch.
