Cyber Risks · Trail of Bits Blog

Numbers turned weapons: DoS in Osmosis’ math library

Summary: Trail of Bits disclosed a vulnerability in the Osmosis chain's math library, where the exponentiation function PowApprox used a Taylor series approximation with an unbounded while loop, so hand-picked inputs like 1.99999999999999^0.1 take over two million iterations and run for over 800 milliseconds on an M1 processor. Because that runtime is not reflected in gas costs, an attacker could craft a transaction calling PowApprox through a swap pool deposit, repeatedly deposit and withdraw 0.99999999999999 token A, and halt the chain; Osmosis fixed it by limiting loop iterations and reverting when the limit is reached, with the bug reported September 6, 2023, a fix PR merged October 6, 2023, and a hard fork on October 23, 2023.

Why it matters: Osmosis users exchange hundreds of thousands of dollars of value daily through its pools, and a single under-a-second computation that gas never priced was enough to stop the whole chain.

Read the original at Trail of Bits Blog ↗