May 4, 2026·5 min read·16 visits
A malicious Rust crate named `mysten-metrics` executes data exfiltration scripts via `build.rs` upon compilation. Developers who compiled this crate must assume their local environment is compromised and immediately rotate all local and cloud credentials.
The `mysten-metrics` Rust crate was published as a malicious package to the crates.io registry. It utilizes a malicious `build.rs` script to execute arbitrary code during the compilation phase, enabling the silent exfiltration of sensitive developer environment variables, SSH keys, and cloud credentials to an external server.
The mysten-metrics package was published to the Rust crates.io registry as a malicious payload disguised as a legitimate library. The crate impersonates infrastructure components associated with the Mysten Labs ecosystem to trick developers into including it in their dependency trees. The registry maintainers removed the package after identifying its malicious behavior.
This incident represents a direct supply chain attack leveraging the Rust build process. The package contained a single version (0.1.0) and lacked any legitimate functional code or external dependencies. Its sole purpose was to execute malicious routines during the compilation phase on the developer's machine or within a continuous integration pipeline.
The vulnerability class is categorized as Embedded Malicious Code (CWE-506). Because the payload triggers automatically upon compilation, the attack requires minimal interaction from the victim beyond the initial inclusion of the dependency. The exfiltration of environment variables and configuration files presents a severe risk to organizational security.
The attack vector relies on the standard functionality of build.rs scripts within the Cargo build system. Cargo allows crate authors to include a build script to perform pre-compilation tasks such as generating bindings, compiling C code, or setting configuration flags. This script compiles and runs on the host machine before the main crate compilation begins.
When a developer executes cargo build, cargo test, or cargo check, Cargo automatically compiles the build.rs file into an executable and runs it. The executable runs with the exact same privileges as the user invoking the Cargo command. Cargo does not sandbox or restrict the system access of the build script by default.
The malicious actor abused this design by placing data exfiltration routines directly inside the build.rs file. Because the package possessed no legitimate functionality, the build script served exclusively as the payload delivery mechanism. The lack of execution boundaries allows the script to read arbitrary files and open outbound network connections without user consent or notification.
The execution of the malicious payload requires the victim to add mysten-metrics to their Cargo.toml file and run a Cargo command. Once triggered, the compiled build.rs executable scans the local environment for sensitive configuration files and credentials. Targets specifically include standard paths for SSH keys, Cargo registry tokens, and cloud provider configuration files.
After gathering local files, the script iterates through all active environment variables accessible to the build process. Environment variables frequently contain API keys, database connection strings, and continuous integration secrets. The collected data is then serialized into a JSON payload or encoded format for transmission.
The final stage of the exploit involves transmitting the gathered secrets to an external server controlled by the attacker. The script uses standard network sockets to execute an HTTP POST request containing the stolen data. The process occurs silently in the background, allowing the standard build process to fail or complete without explicitly alerting the developer to the data theft.
The impact of compiling the mysten-metrics crate is the immediate and silent compromise of the host environment. An attacker gains access to all secrets readable by the user executing the build command. This typically includes source code repository access, cloud infrastructure control, and internal network credentials.
If the crate is compiled on a developer's local workstation, the attacker obtains personal access tokens and SSH keys, enabling lateral movement into organizational repositories. If compiled within a Continuous Integration/Continuous Deployment (CI/CD) pipeline, the impact often escalates to complete infrastructure compromise. CI/CD environments routinely hold highly privileged service account credentials required for production deployments.
The exfiltration occurs instantly upon the first build attempt. There is no persistence mechanism required for the attacker to achieve their primary objective. The compromised credentials can be utilized immediately or sold to initial access brokers, making rapid incident response critical.
Organizations must assume full environment compromise if the mysten-metrics crate was downloaded and compiled. The primary remediation step requires the immediate rotation of all secrets present on the affected machine or CI/CD runner. This includes resetting cloud provider credentials, revoking SSH keys, and generating new API tokens.
Developers must remove the dependency from all Cargo.toml files and audit their Cargo.lock files to ensure no transitive inclusion occurred. Local environments require sanitization by running cargo clean and clearing the Cargo registry cache located at ~/.cargo/registry/. Security teams should review network logs for outbound connections from build machines to identify successful exfiltration events.
To prevent future supply chain compromises, development teams should implement dependency auditing tools such as cargo-audit. Organizations should also explore sandboxing local build environments and CI/CD runners to restrict outbound network access and file system reads during the compilation process.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
mysten-metrics crates.io | All versions (including 0.1.0) | None (Removed) |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-506 |
| Attack Vector | Supply Chain / Malicious Dependency |
| Execution Trigger | cargo build / compilation phase |
| Exploit Status | Active |
| Target Operating Systems | All OS (Cross-platform execution) |
| Impact | High (Data Exfiltration / Credential Theft) |
Embedded Malicious Code that performs actions contrary to the security interests of the developer.
The @jhb.software/payload-cloudinary-plugin exposes an endpoint that performs unvalidated cryptographic signing of Cloudinary API parameters, allowing authenticated users with minimal privileges to forge valid signatures for arbitrary actions. This flaw allows attackers to overwrite remote storage assets, execute unauthorized file uploads, alter asset visibility parameters, trigger SSRF webhooks, and perform directory traversal within Cloudinary repositories.
A Server-Side Request Forgery (SSRF) and Bearer Token Exfiltration vulnerability exists in the @merill/lokka (Lokka) Model Context Protocol (MCP) server prior to version 2.1.2. The server constructed Azure Resource Manager request URLs by concatenating user-controlled path parameters directly into destination request strings. By injecting authority-redefinition characters, an attacker can manipulate URL parsing to execute a host-escape attack, forcing the server to send high-privilege Azure Resource Manager (ARM) Bearer tokens to an external attacker-controlled host. This allows complete administrative access to the associated Azure subscriptions.
A directory traversal and symlink following vulnerability exists in Pydantic Settings when using the NestedSecretsSettingsSource with nested subdirectory lookups enabled. An attacker capable of writing to the secrets directory can bypass size limitations, read arbitrary host files, or cause a denial-of-service condition via cyclic symlinks.
A Server-Side Request Forgery (SSRF) vulnerability exists in SurrealDB's Identity & Access Management (IAM) module prior to version 3.1.5. When configuring JSON Web Key Set (JWKS) URLs for token verification, the remote fetcher follows HTTP redirects by default without validating redirect targets against configured network capabilities. This allows high-privileged users to bypass network access limits and perform blind port scanning of internal network resources.
A local file disclosure vulnerability exists in SurrealDB's full-text search capabilities, allowing authenticated users with database EDITOR or OWNER roles to read arbitrary files from the host system filesystem. This occurs by abusing the mapper() filter inside a DEFINE ANALYZER statement to point to system files.
SurrealDB versions 3.0.0 through 3.1.4 contain an information exposure vulnerability (CWE-203) where the query planner optimizes sorted queries using indexes on fields with field-level SELECT restrictions. Because the query planner performs index-based sorting before enforcing permission-based redaction, unauthorized users can observe the physical order of returned rows to deduce the relative values of protected fields.