Reproduced Exploit

Rubicon — Precision loss makes openPosition leverage higher than expected

wmul floor makes desired==init; lastBorrow=0 is treated as full borrow instead of zero extra leverage.

Apr 2023Otheruntagged2 min read

Chain

Other

Category

untagged

Date

Apr 2023

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 48955-h-16-due-to-the-loss-of-precision-openposition-will-make-the. Standalone Foundry PoC and full write-up: 48955-h-16-due-to-the-loss-of-precision-openposition-will-make-the_exp in the evm-hack-registry mirror.


Vulnerability classes: precision-loss · integer-bounds · liquidation-underwater

Reproduction: self-contained Foundry PoC with only forge-std — no fork, no RPC. Full trace: output.txt. PoC: test/48955-h-16-due-to-the-loss-of-precision-openposition-will-make-the_exp.sol.


Key info#

ImpactHIGH — leverage=1e18+1 floors desired to initMargin; lastBorrow=0 triggers 100% CF borrow (~1.7x)
ProtocolRubicon
Bug classprecision-loss · integer-bounds · liquidation-underwater
FindingCode4rena 2023-04-rubicon · #48955 · H-16 · reporter cccz
Reportcode4rena.com/reports/2023-04-rubicon
SourceAuditVault
StatusConfirmed. Reproduced as a standalone local synthetic.
Compiler^0.8.24 (PoC)

TL;DR#

wmul floor makes desired==init; lastBorrow=0 is treated as full borrow instead of zero extra leverage.


The vulnerable code#

See synthetic test/48955-h-16-due-to-the-loss-of-precision-openposition-will-make-the.sol (@> VULN markers).

Fix: Treat lastBorrow==0 with no excess as zero borrow; tighten leverage precision.


Root cause#

wmul floor makes desired==init; lastBorrow=0 is treated as full borrow instead of zero extra leverage.


Preconditions#

Protocol deployed with the vulnerable code paths from the Code4rena contest.


Attack walkthrough#

See PoC run() and output.txt.


Diagrams#

sequenceDiagram participant User participant Protocol User->>Protocol: trigger vulnerable path Protocol->>Protocol: hit @> VULN line Protocol-->>User: harm realized

Impact#

leverage=1e18+1 floors desired to initMargin; lastBorrow=0 triggers 100% CF borrow (~1.7x)


Taxonomy#

  • genome: precision-loss · integer-bounds · liquidation-underwater
  • severity/high · platform/code4rena

Sources#


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • Web3Sec X hacked database: search.
  • Rekt leaderboard: search.
  • Solodit incident search: search.

These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.