Simplified version: A straightforward "translation" and interpretation of the technical analysis by experts regarding the @CetusProtocol hacking incident: This attack exposed a classic integer overflow issue, specifically data truncation during type conversion. Technical details breakdown: 1) Vulnerability location: The issue lies in the type conversion mechanism of the get_amount_by_liquidity function, where forced conversion from u256 to u64 results in high-order data loss. 2) Attack process: 1. The attacker passes an extremely large liquidity amount parameter through the add_liquidity function; 2. The system calls the get_delta_b function to calculate the required amount of token B; 3. During the calculation, two u128 type data values are multiplied, and the theoretical result should be of u256 type; Key flaw: When the function returns, the u256 result is forcibly converted to u64, causing the high-order 128-bit data to be truncated. 3) Exploitation effect: Liquidity that originally required a large amount of tokens to mint can now be achieved with a minimal amount of tokens. The attacker gains a massive liquidity share at a very low cost and subsequently exploits the liquidity pool for arbitrage by destroying part of the liquidity. Simple analogy: It's like using a calculator that can only display 8 digits to compute 1 billion × 1 billion. The 20-digit result can only show the last 8 digits, while the first 12 digits disappear. The attacker exploited this "calculation precision loss" vulnerability. One thing needs to be clarified: This vulnerability is unrelated to the underlying security architecture of @SuiNetwork. The security "glory" of the Move language remains trustworthy for now. Why? The Move language indeed has significant advantages in resource management and type safety, effectively preventing double-spending, resource leaks, and other underlying security issues. However, the Cetus protocol's issue stems from a mathematical calculation error at the application logic layer, not a design flaw in the Move language itself. Specifically, while Move's type system is strict, it still relies on developers' correct judgment for explicit type conversion operations. When a program actively performs a type conversion from u256 to u64, the compiler cannot determine whether this is intentional or a logical error. Moreover, this security incident is entirely unrelated to Sui's consensus mechanism, transaction processing, state management, or other core underlying functionalities. Sui Network merely faithfully executed the transaction instructions submitted by the Cetus protocol, and the vulnerability originated from the logical flaws in the application layer protocol itself. In simple terms, no matter how advanced a programming language is, it cannot completely eliminate logical errors at the application layer. Move can prevent most underlying security risks but cannot replace developers in performing boundary checks for business logic and overflow protection for mathematical operations.
After investigating the Cetus exploit transaction, I believe I have identified the root cause of the bug. The issue stems from a type casting from u256 to u64 within the get_amount_by_liquidity function.
Show original
151
53.46K
The content on this page is provided by third parties. Unless otherwise stated, OKX is not the author of the cited article(s) and does not claim any copyright in the materials. The content is provided for informational purposes only and does not represent the views of OKX. It is not intended to be an endorsement of any kind and should not be considered investment advice or a solicitation to buy or sell digital assets. To the extent generative AI is utilized to provide summaries or other information, such AI generated content may be inaccurate or inconsistent. Please read the linked article for more details and information. OKX is not responsible for content hosted on third party sites. Digital asset holdings, including stablecoins and NFTs, involve a high degree of risk and can fluctuate greatly. You should carefully consider whether trading or holding digital assets is suitable for you in light of your financial condition.