Reproduced Exploit
Plaza Finance: BondOracleAdapter returns a Q64.96 price as a Chainlink answer
Sherlock issue 1016 feeds a USDC/WETH sqrt of 1390618563380010078436460929963734 through getPriceX96FromSqrtPriceX96 and gets 24408239790603697707980053009065971527. That is the number latestRoundData returns. Scaled to 18 decimals the same observation is 3245959692053023671448, about 3245.96 USDC…
Loss
1 wei of collateral borrows 24.408 USDC. The 18-decimal price of the same observation is about 3245.96
Chain
Ethereum
Category
oracle
Date
Dec 2024
Source
AuditVault
EVM Playground
Source-level debugger — step opcodes and Solidity in sync
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. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.
Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 49240-h-11-incorrect-price-representation-sherlock-plaza-finance-g. Standalone Foundry PoC and full write-up: 49240-h-11-incorrect-price-representation-sherlock-plaza-finance-g_exp in the
evm-hack-registrymirror.
Vulnerability classes:
vuln/oracle/wrong-feed·vuln/arithmetic/decimal-mismatch
Key info#
| Field | Value |
|---|---|
| Loss | 1 wei of collateral borrows 24.408 USDC. The 18-decimal price of the same observation is about 3245.96 |
| Vulnerable contract | BondOracleAdapter.latestRoundData |
| Attacker EOA | 0x1111111111111111111111111111111111111111 |
| Attack contract | Exploit |
| Attack tx | Exploit.run() |
| Chain / block / date | Ethereum model · block 0 · 2024-12 |
| Compiler | solc 0.8.27, cancun, via IR |
| Bug class | latestRoundData returns sqrtPrice^2 / 2^96 with no decimal conversion |
TL;DR#
Sherlock issue 1016 feeds a USDC/WETH sqrt of 1390618563380010078436460929963734 through getPriceX96FromSqrtPriceX96 and gets 24408239790603697707980053009065971527. That is the number latestRoundData returns. Scaled to 18 decimals the same observation is 3245959692053023671448, about 3245.96 USDC per WETH. A vault that treats the answer as an 18-decimal Chainlink price lends answer / 1e18 against 1 wei of collateral and pays out 24.408 USDC. At the fair price, 1 wei is worth 3245 wei.
The vulnerable code#
return (uint80(0), int256(getPriceX96FromSqrtPriceX96(getSqrtTwapX96)), block.timestamp, block.timestamp, uint80(0)); // @> VULN
The report's conversion, for a 6-decimal token0 and an 18-decimal token1, is:
return (10 ** 30) * Q96 / priceX96;
Root cause#
getPriceX96FromSqrtPriceX96 divides the square of the sqrt price by 2^96. That quotient is still a Q64.96 price. latestRoundData puts it in the Chainlink answer slot, whose consumers divide by 10^decimals. Nothing in the adapter applies the token decimals or the 2^96 scale a second time.
Preconditions#
- The pool's
observereturns the tick window from the report: cumulative delta12000000over a 60 secondtwapInterval, tick 200000. - That tick's sqrt is the report's
sqrtPriceX96. The product fits in a uint256, soFullMath.mulDivand a plain multiply match. - The vault prices collateral as
answer * amount / 1e18and holds exactly that many quote tokens.
Attack walkthrough#
latestRoundDatareads the pool and returns the raw priceX96. The exploit checks it against24408239790603697707980053009065971527and checks the 18-decimal conversion against3245959692053023671448.- The vault is funded with
priceX96 / 1e18, which is24408239790603697707wei, about 24.408 tokens. borrow(1)multiplies the oracle answer by 1 wei and divides by 1e18.- The vault transfers that whole amount. Its balance is 0. The borrower holds 24.408 USDC against 1 wei of collateral.
Diagrams#
Impact#
Every consumer that assumes an 18-decimal Chainlink answer mis-values the asset by many orders of magnitude. In this vault, 1 wei of collateral extracts 24.408 USDC, the entire funded balance. The fair value of that wei at the report's own converted price is 3245 wei. The same wrong answer feeds every other calculation the adapter is wired into.
How to reproduce#
cd 49240-h-11-incorrect-price-representation-sherlock-plaza-finance-g_exp
forge test -vv
test_priceX96_is_lent_as_an_18_decimal_price asserts the raw answer, the fair 18-decimal price, and a borrower balance of 24408239790603697707.
Sources#
- AuditVault finding: https://github.com/Auditware/AuditVault/blob/main/findings/49240-h-11-incorrect-price-representation-sherlock-plaza-finance-g.md
- Sherlock judging issue 1016: https://github.com/sherlock-audit/2024-12-plaza-finance-judging/issues/1016
- Adapter: https://github.com/sherlock-audit/2024-12-plaza-finance/blob/14a962c52a8f4731bbe4655a2f6d0d85e144c7c2/plaza-evm/src/BondOracleAdapter.sol#L99
- Fix: https://github.com/Convexity-Research/plaza-evm/pull/158
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 49240-h-11-incorrect-price-representation-sherlock-plaza-finance-g_exp (evm-hack-registry mirror).
- AuditVault finding: 49240-h-11-incorrect-price-representation-sherlock-plaza-finance-g.
Alerts & third-party analyses
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.