Reproduced Exploit
Xyro: an exact-price tie pays both stakes to the opponent
Settlement pays the initiator only when their guess is strictly closer. If both guesses are the same distance from the price, the else branch pays the opponent the combined stake. Price mark 100, initiator 90, opponent 110. Both distances are 10. The opponent receives 20 ETH and the initiator recei…
Loss
Initiator's 10 ETH stake paid to the opponent. Opponent ends with 20 ETH
Chain
Ethereum
Category
logic
Date
Aug 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: 45675-the-opponent-has-a-higher-probability-of-winning-than-the-in. Standalone Foundry PoC and full write-up: 45675-the-opponent-has-a-higher-probability-of-winning-than-the-in_exp in the
evm-hack-registrymirror.
Vulnerability classes:
vuln/logic/wrong-condition·vuln/logic/missing-check
Key info#
| Field | Value |
|---|---|
| Loss | Initiator's 10 ETH stake paid to the opponent. Opponent ends with 20 ETH |
| Vulnerable contract | OneVsOneExactPrice.finalize |
| Attacker EOA | 0x1111111111111111111111111111111111111111 |
| Attack contract | Exploit |
| Attack tx | Exploit.run() |
| Chain / block / date | Ethereum model · block 0 · 2024-08 |
| Compiler | solc 0.8.27, cancun, via IR |
| Bug class | diff1 < diff2 pays the initiator. Every other case, including a tie, pays the opponent |
TL;DR#
Settlement pays the initiator only when their guess is strictly closer. If both guesses are the same distance from the price, the else branch pays the opponent the combined stake. Price mark 100, initiator 90, opponent 110. Both distances are 10. The opponent receives 20 ETH and the initiator receives 0. A tie refunds 10 ETH to each player.
Background#
Zokyo's 29 August 2024 Xyro review of OneVsOneExactPrice. Players cannot submit the same price, but they can still land equally far from the settlement price, one above and one below.
The vulnerable code#
if (diff1 < diff2) {
treasury.distribute(g.depositAmount * 2, g.initiator, g.depositAmount, g.fee);
} else {
// @> VULN: a tie (diff1 == diff2) pays the opponent instead of refunding both stakes
treasury.distribute(g.depositAmount * 2, g.opponent, g.depositAmount, g.fee);
}
finalPrice / 1e14 is 100. diff1 is 100 - 90. diff2 is 110 - 100. The comparison is false, so the opponent is paid depositAmount * 2.
Root cause#
Equality is not a third outcome. The else branch treats a tie as an opponent win.
Preconditions#
- Each player escrows 10 ETH. The initiator's price is 90 and the opponent's is 110.
- Settlement price divides by
1e14to 100. Fee is 0. finalizeis callable once both stakes are in the treasury. It is not an owner-only action.
Attack walkthrough#
- Both players approve and
createGamepulls 10 ETH from each into the treasury. finalizecomputes both distances as 10.- The else branch sends 20 ETH to the opponent.
- The initiator balance is 0. The treasury is empty.
- The control refunds 10 ETH to each address when the distances are equal.
Diagrams#
Impact#
The initiator loses the 10 ETH stake on a tie that should have been a push. The opponent is paid as if they were strictly closer. Every equal-distance game mis-pays the same way.
Remediation#
If diff1 == diff2, refund each deposit and finish the game. Pay the opponent only when diff2 < diff1.
How to reproduce#
cd 45675-the-opponent-has-a-higher-probability-of-winning-than-the-in_exp
forge test -vv
test_exploit_tie_pays_the_opponent asserts the opponent holds 20 ETH and the initiator holds 0. test_control_tie_refunds_both_players asserts each holds 10 ETH. Captured output is output.txt.
Sources#
- AuditVault finding: https://github.com/Auditware/AuditVault/blob/main/findings/45675-the-opponent-has-a-higher-probability-of-winning-than-the-in.md
- Zokyo report: https://github.com/solodit/solodit_content/blob/main/reports/Zokyo/2024-08-29-Xyro.md
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 45675-the-opponent-has-a-higher-probability-of-winning-than-the-in_exp (evm-hack-registry mirror).
- AuditVault finding: 45675-the-opponent-has-a-higher-probability-of-winning-than-the-in.
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.