Skip to content
Smart contracts Write-up Intermediate

Hack Analysis Uranium Finance April 2021

Uranium Finance's AMM pair contracts used a fee scaling factor of 10000 in the balance adjustment but kept the original 1000 in the K invariant check, making the check 100 times too lenient. An attacker could swap a tiny amount of one token for nearly the entire balance of the other token in a pair, draining liquidity.

immunefi.com

Published on immunefi.com

On April 28, 2021, Uranium Finance, an AMM deployed on BNB Chain, was the victim of a not-so-sophisticated heist. This heist resulted in the loss of over $50m worth of tokens across 26 different market pairs and was one of the most devastating attacks in DeFi at the time and remains one of the most devastating on BNB…

The author, on immunefi.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the fee scaling constant was updated to 10000 in the balance adjustment but the K invariant check still multiplied the reserves by 1000 squared, so the check was 100 times weaker than intended.

Impact

The attacker could drain nearly all liquidity from a pair, and the article states the original heist stole over $50m across 26 pairs; the PoC on one pair yielded over $16m.

What the attacker needed

Access to BNB Chain archive node; some BNB for gas and initial swap; target pair has liquidity

How it was found

  1. Send BNB to the attack contract
  2. Wrap the BNB into WBNB
  3. Send a small amount of WBNB to the target pair contract
  4. Call swap() on the pair to drain BUSD
  5. Send a small amount of BUSD to the same pair contract
  6. Call swap() again to drain WBNB

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

An automated market maker (AMM) is a smart contract that lets people trade tokens directly with a pool. It relies on a simple rule: after a trade, the product of the two token balances must not decrease. Uranium Finance changed the numbers in that rule by mistake, so the check became far too weak and someone could take almost all the tokens from the pool for very little in return.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.