The Cetus Hack on Sui Explained: A Faulty Overflow Check
Quick answer. On May 22, 2025, an attacker drained about $223 million from Cetus, a Sui exchange, through a faulty overflow check in the integer-mate math library. A one-token deposit bought enormous liquidity; Sui validators froze $162 million.
Video transcript
An attacker drained about 223 million dollars from Cetus, a Sui exchange, in May 2025. The flaw sat in an imported math library, not the exchange logic.
With a flash swap, the attacker opened a narrow position, paid one unit of a token for enormous liquidity, then withdrew it as real tokens.
One overflow check in integer-mate used the wrong mask. Oversized values passed, a 64-bit left shift dropped their high bits, and the required deposit became tiny.
Move aborts on overflow in addition, subtraction and multiplication. A left shift that loses bits does not, so the library's own check was the only guard.
A Sui validator vote froze about 162 million dollars, later recovered by a governance vote. Over 60 million had already been bridged to Ethereum.
Zellic, whose latest Cetus audit finished in April 2025, told Rekt the library was outside its scope. Yet a library is code you ship.
Put every library in audit scope. Test overflow checks at their exact boundary. Write an invariant that no deposit mints more than it pays in, fuzz near type limits, and re-run on every dependency change.
Guardian's audits turn math formulas into invariants fuzzed across every reachable state. Managed Security's Helix AI auditor runs continuously across your stack.
Read the full breakdown, or talk to Guardian about testing the libraries your contracts trust.
The Cetus hack on Sui is a dependency story. The flawed code sat in integer-mate, a math library Cetus's contracts import, not in the exchange logic itself.
Zellic, whose latest Cetus audit finished on April 11, 2025, told Rekt that "the integer-mate library was not included in the scope of our audit."
The bug was one faulty check. Here is how it worked, how Sui's validators froze most of the funds, and what it means for any team that imports math.
What Happened
Cetus runs concentrated liquidity pools. Providers deposit two tokens into a chosen price range, measured in ticks.
The attacker funded the setup with a flash swap, then opened a position in a very narrow range: ticks 300,000 to 300,200, Dedaub reported.
It added liquidity of about 10^34 units while paying in a single unit of one token. Dedaub gives the exact figure: 10,365,647,984,364,446,732,462,244,378,333,008.
The pool booked that liquidity as real. The attacker removed it over several transactions, draining the pool, and repaid the flash swap, Dedaub found.
The checked_shlw Bug
To price a deposit, Cetus's get_delta_a function shifts an intermediate value left by 64 bits. It runs that shift through checked_shlw in integer-mate, which is meant to flag overflow.
Here is the check as Dedaub published it:
public fun checked_shlw(n: u256): (u256, bool) {
let mask = 0xffffffffffffffff << 192; // This is incorrect!
if (n > mask) {
(0, true)
} else {
((n << 64), false) // exact location of overflow
}
}
Any value at or above 2^192 overflows when shifted 64 bits. Dedaub says the developers "likely intended to check if n >= (1 << 192)."
Instead, the mask works out to 2^256 minus 2^192, close to the u256 maximum. Values between the two passed the check, and the shift dropped their high bits.
The truncated number made the required deposit tiny, Dedaub explains. So one token paid for liquidity that let the attacker withdraw most of the pool.
Cetus patched integer-mate on May 22, the day of the attack. Its commits change the mask to 1 << 192 and the comparison from > to >=.
Why Move shifts do not abort
Move is built to fail safe on math. Its reference says: "All arithmetic operations abort instead of behaving in a way that mathematical integers would not."
That covers addition, subtraction and multiplication. Shifts are different: they abort only when the shift amount is too large for the type.
A left shift that pushes bits off the top does not abort. As Dedaub put it, the left shift "uniquely, does not abort in the event of an overflow."
So the library's hand-written check was the only guard, and it was wrong.
Timeline and Loss
Figures are from Cetus's incident report, as The Block summarized it, unless noted.
- May 22: the attack drains about $223 million. Core pools are disabled within 30 minutes.
- Within 1 hour 20 minutes: Sui validators begin voting to reject the attacker's transactions.
- Freeze: once the vote passes 33% of stake, addresses holding about $162 million are frozen.
- Bridged out: over $60 million had already gone to Ethereum via Wormhole, Rekt reported.
- May 29: a Sui vote to recover the frozen funds passes with 90.9% in favor, Cointelegraph reported.
- June 8: Cetus restarts, with affected pools refilled to 85% to 99% of their liquidity.
The refill drew on the recovered $162 million, Cetus's entire $7 million cash reserves and a $30 million USDC loan from the Sui Foundation, The Block reported.
The rest is paid in CETUS tokens over 12 months, an amount that could shrink if more funds are recovered from the attacker.
What It Shows
A library is code you ship. Zellic's scope left out integer-mate, yet Cetus priced liquidity deposits through it.
Language safety has edges. Move aborts on arithmetic overflow, but not when a left shift loses bits, so that check falls to the developer.
Copied code copies bugs. Rekt, citing a Verichains review, called checked_shlw "copy-pasted across the ecosystem."
After the hack, Cetus committed to deeper test coverage, real-time monitoring and public code coverage metrics. Its June 2025 integer-mate commits aim for 100% test coverage.
A checklist for any team that imports math:
- List every library your contracts call, including your own, and put it in audit scope.
- Test each overflow check at its exact boundary: one below, at, and one above.
- Write an invariant: no deposit may mint liquidity worth more than it pays in.
- Fuzz with extreme ticks and amounts near type limits.
- Re-run the suite whenever a dependency changes.
For more, see our guide to smart contract audit scoping and our study of audited vs unaudited exploits. For another 2025 math bug, read the Balancer exploit post-mortem.
How Managed Security Tests Dependencies
Guardian's Managed Security cites Cetus under continuous vulnerability testing: "Our AI agents spend billions of tokens continuously auditing your entire stack."
Here is how the site describes that work.
- Helix: Guardian's AI auditor runs continuously across your contracts, backend, infrastructure and web app.
- Repositories: Helix audits every repository you choose to share.
- Findings: only human-verified findings reach you, each with a fix PR.
- Disclosures: advisories are matched to what you run, and an engineer confirms any exposure.
Guardian's smart contract audit includes an invariant suite. Core safety properties, such as rounding and math formulas, become executable invariants fuzzed across every reachable state.
Frequently Asked Questions
How was Cetus hacked on Sui?
Through a faulty overflow check in checked_shlw, a function in the integer-mate math library. A wrong mask let a 64-bit left shift overflow silently, so a one-token deposit bought enormous liquidity, which the attacker withdrew as real tokens.
How much did Cetus lose?
About $223 million, per Cetus. Sui validators froze about $162 million, later recovered through a governance vote, and over $60 million was bridged to Ethereum, Rekt reported.
Why didn't Move's overflow protection stop it?
Move aborts on arithmetic overflow, but a left shift aborts only if the shift amount is too large. Bits pushed off the top are lost without an abort, so the library's own check was the only guard.
Was the buggy library audited?
Not in Zellic's audit. Zellic, whose latest Cetus audit finished on April 11, 2025, told Rekt that "the integer-mate library was not included in the scope of our audit."
Sources
- The Block: Sui DEX Cetus says overlooked flaw in open-source library used by smart contract led to $223 million exploit (May 27, 2025)
- Dedaub: The Cetus AMM $200M Hack, How a Flawed Overflow Check Led to Catastrophic Loss (May 23, 2025)
- Rekt: Cetus, Rekt (May 23, 2025)
- CetusProtocol on GitHub: integer-mate, Fix checked_shlw in math_u256 module (May 22, 2025)
- CetusProtocol on GitHub: integer-mate, Fix checked_shlw (May 22, 2025)
- CetusProtocol on GitHub: integer-mate commit history, including June 2025 test coverage work
- Move language on GitHub: The Move Book, Integers
- Cointelegraph: Sui community passes vote to repay $162M to Cetus exploit victims (May 30, 2025)
- The Block: Sui DEX Cetus Protocol restarts platform after recovering from $223 million exploit (June 8, 2025)
- Guardian: Managed Security
- Guardian: Smart Contract Audit
Test the libraries your contracts trust
Guardian Managed Security runs Helix continuously across your repositories, with each finding confirmed by an engineer and delivered as a fix PR.