Write-up for LatentRisk
Overview
Numerous projects have suffered exploits due to the round-down vulnerability present in the very early stages of Web 3. This challenge was inspired by an incident that happened in the Compound v2 fork, and it was crafted to inform about potential threats that exist in Compound v2.
Please note that Compound v2 has known about this for a long time, and they've never encountered any problems due to this.
I hope every builder/developer/security researcher acknowledges this latent risk and does not reproduce the same crisis anymore.
Solving the puzzle
Compound v2 utilizes interest-bearing tokens (ibTokens) named cToken
to manage lender and borrower positions, which can be managed by comptroller
, the controller in Compound v2. However, if you accept cToken
as collateral before any issuance of cToken
, you can exploit a round-down vulnerability to drain all other underlying assets of cToken
.
The root cause is that the exchange rate of cToken
can be manipulated at the attacker's will when no liquidity exists, and a round-down occurs in redeemUnderlying()
. As a result, an attacker can borrow other underlying assets of cToken
without collateral.
If you are interested in learning more, check out our blog post.
Solve script
Check out our solve test below for more details.