Early rate$2,400 of senior audit time for $500. Early members keep the rate as it climbs.$2,400 of senior audit time for $500See how

Unsafe Downcast

A narrowing integer conversion that silently truncates instead of reverting when the value does not fit.

An unsafe downcast is an explicit conversion of an integer to a smaller type — uint128(x), uint64(x), int32(x) — where the value does not fit in the destination type. Solidity does not revert on this. It truncates, keeping only the low-order bits, and execution continues with a silently wrong number.

Why it survives Solidity 0.8

Solidity 0.8 introduced checked arithmetic for +, - and *, which is why overflow is often treated as a solved problem. Explicit casts were never included in that change. uint128(someHugeValue) truncates in 0.8.x exactly as it did in 0.6.x. Any codebase that upgraded the compiler and assumed narrowing conversions became safe is mistaken.

The pathological case is a value that truncates to exactly zero. Casting 2^128 into a uint128 does not produce a large number or an error — it produces 0, which then flows into downstream logic as a completely legitimate-looking quantity.

Why it is dangerous on value paths

A truncated number does not announce itself. Every check downstream of the cast runs correctly, on a value that has already lost the information those checks existed to evaluate:

  • A debt of 2^128 truncated to 0 passes a solvency check as fully collateralised
  • A fee, share count or collateral amount truncated to 0 passes a non-zero check that was applied before the cast
  • A comparison against a bound succeeds because the value no longer exceeds it

In the September 2026 Notional V1 exploit, an unchecked uint128(balance.abs()) inside the free-collateral valuation turned an fCash liability of -2^128 into 0. The collateral check then correctly approved an account carrying an enormous unbacked debt.

In audit scope

Walk every value-bearing numeric pipeline backwards from each security check to its input sources, and flag every narrowing cast, unchecked block, unit conversion and signed-to-unsigned transition along the way. Use OpenZeppelin's SafeCast (or an equivalent reverting cast) on any path where the value influences solvency, collateral, shares or authorisation.

Need expert guidance on Unsafe Downcast?

Our team at Zealynx has deep expertise in blockchain security and DeFi protocols. Whether you need an audit or consultation, we're here to help.

Get a Quote