Skip to main content

On This Page

Three Sui Exploits, One Root Cause: Why 'The Math Looked Fine' Keeps Costing $224M+

2 min read
Share

These articles are AI-generated summaries. Please check the original sources for full details.

Three Sui Exploits, One Disease — Why ‘The Math Looked Fine’ Keeps Costing Hundreds of Millions

A single missing comparison cost Cetus $223M, Aftermath $1.14M, and Bucket Protocol remains vulnerable. All three passed audits by top firms.

Why This Matters

Three Sui protocols – Cetus, Aftermath, and Bucket – lost or risk losing over $224 million to arithmetic bugs that all passed audits. The ideal of safe smart contracts breaks on a single missing comparison, because Move’s compile-time guarantees stop at integer overflow. The real cost of invisible boundary errors is nine figures, and the fix is always one line.

Key Insights

  • Cetus lost $223M in May 2025 due to a shift overflow in checked_shlw – the assert was off by one bit (source: Cyfrin).
  • Aftermath lost $1.14M in April 2026 from a negative fee – only upper bound validated, signed comparison passed (source: DarkNavy).
  • Bucket Protocol’s debt health functions can overflow when collateral decimals exceed BUCK decimals – found July 2026, unpatched (source: OtterSec audit).
  • Auditors miss arithmetic bugs because the check looks complete – rational under time pressure; static analysis catches them in milliseconds.
  • Move’s safety guarantees prevent reentrancy and type errors but not integer overflow – the gap is at the math layer.

Working Examples

Cetus’s checked_shlw function – the assert passes incorrectly for inputs near 2^192, causing a shift overflow.

// BEFORE fix
assert!(n <= MAX_U256 >> 64, ERR_OVERFLOW);
n << 64

Aftermath’s fee validation – only upper bound checked, allowing negative fees to pass.

assert!(integrator_taker_fee <= max_taker_fee, E_INVALID);

Bucket Protocol’s compute_collateral_value_to_buck – u64 multiplication after safe u128 promotion, risking overflow.

let collateral_raw_value = mul_factor(collateral_amount, price, denominator);
collateral_raw_value * pow(10, constants::buck_decimal() - collateral_decimal)

Practical Applications

  • Use case: Cetus uses checked_shlw in liquidity delta calculation – pitfall: relying on a library function whose assert is mathematically incomplete.
  • Use case: Aftermath allows third-party fee setting – pitfall: only upper bound check, enabling negative fees that inflate collateral.
  • Use case: Bucket Protocol’s create_bucket adds new collateral with arbitrary decimals – pitfall: no overflow guard in compute_collateral_value_to_buck, safe only by accident today.

References:

Continue reading

Next article

"Refactor vs Rewrite Decision Tree for Engineers", "pubdate": "2026–07–27", "description": "Six-question framework evaluates whether incrementally refactoring legacy code outweighs strategic full-system rewrite.", "categories": ["Software Engineering", "Best Practices"], "mainheading": "A decision tree for grown engineers", "hook": { "sentences": [ "Edgar Nahama Alochi published an engineer’s guide distinguishing emotional rewrites from strategic ones.", "Most teams do not need rewrites — they need tests, clearer boundaries, smaller pull requests, and patience." ] }, "whythismatters": { "paragraph": "Engineering teams frequently conflate personal frustration with architectural necessity when considering rewrites versus refactors." +" While clean-slate approaches feel productive initially they erase hard-won production knowledge embedded in legacy code," +" often creating regression generators instead of improved systems." +" The economic cost of unnecessary rewrites includes months of slowed feature delivery plus reintroduction of bugs already fixed." +" Technical leaders must distinguish when change cost compounds structurally versus when discomfort stems only from poor naming or style." }, "keyinsights": [ {"fact_with_source_year": ": According to Alochi (July ॣ८६),ifasystemworksandgeneratesvalueyouarenonstaringatechnicalproblembutarevenueengine.Preferrefactoringinthatcase."},"]

Related Content