The Register Home Page

back to article Hackers poison popular Rust crates to steal developers' credentials

Hackers slipped malware into several popular Rust packages this week, turning routine software builds into a route onto developers' machines. The Rust Security Response Team disclosed the supply chain attack on Thursday after receiving a tip about a crate called proc-macro1. An investigation found that its build script fetched …

  1. JLV Silver badge
    Boffin

    With increasing attacks via supply-side hacks on dependency repos, hacks that get taken down very quickly, I wonder if anyone’s gone into the business of simply mirroring sites like pypi, npm and cargo.io with a day or two latency?

    Could always push through high-CVE fixes without delay.

    I know there are high value, enterprise-safe services to do this, with a lot more elaborate controls. More thinking the simplest thing possible, either free or low monthly subscription.

    1. iron

      Alternatively just don't update any library where the latest version is less 48 hours old. Requires no extra infrastructure or cost and can even be done with automated tools like dependabot on GitHub.

      1. JLV Silver badge

        That could indeed help on the GitHub side of things. But how does it help as a dev, pulling in packages on your local workstation via uv, pip, npm or cargo, to add to your codebase?

        1. Blazde Silver badge

          For Rust the solution is min-publish-age which already exists in nightly and is now definitely being stabilised for Rust 1.100 (which is sadly now 2.5 months away): https://github.com/rust-lang/cargo/pull/17335

          Edit: Here is a good if already outdated overview of the concept for many other package managers, and I'd especially point to VSCode's 'extensions.autoUpdateDelay' setting: https://nesbitt.io/2026/03/04/package-managers-need-to-cool-down.html

          1. just4this Silver badge

            min-publish-age

            Remember to add a day to that to account for GitHub downtime.

          2. JLV Silver badge

            Wow, that page at nesbitt is a goldmine of things to evaluate as mitigations, thanks.

    2. Charlie Clark Silver badge

      devpi has been around for years for this and other reasons – quite often you don't want the server to have access of this of any kind.

  2. trindflo

    download link in the code?

    Did I misread the article, or is there an obvious malware site linked to in the code? The article claims the poisoned package downloads the malware; can't a check be made on links in the code? Or the build scripts if that is where the malware is introduced?

    1. MonkeyJuice Silver badge

      Re: download link in the code?

      In malware the download links are generally obfuscated. Nothing a reverse engineer couldn't trivially find (after all, the code has to actually produce the link by executing), but enough to throw something like a grep. It's cheap for a bad actor to get detected, they just try again with a different package, and there are infinite ways to obfuscate, so no general mechanism exists, unfortunately.

  3. Anonymous Coward
    Anonymous Coward

    So Many Package Library Poisonings these Days

    (Semi-jokingly) it seems that the only effective way of guaranteeing the integrity of one's own software is by not trusting anyone elses', unless you have reviewed and understood all of their code.

    Due to dependency fan-out, it might be (somewhat) faster to build your own toolchain, bootstrapping from a simple assembler you wrote yourself in machine code.

    The package-poisoning problem is as large as it is because the villains' attack surface is so large. It takes only one careless-or-foolish dev storing credentials in the wrong place, or clicking on the wrong link and compromising their PC, or simply being dilligent-yet-unlucky and having their PC exploited by some 0-day, to bring the whole house of cards down.

    1. David 132 Silver badge
      Thumb Up

      Re: So Many Package Library Poisonings these Days

      "it seems that the only effective way of guaranteeing the integrity of one's own software is by not trusting anyone elses', unless you have reviewed and understood all of their code."

      Ken Thompson's "Reflections on Trusting Trust" comes to mind; truly, there is nothing new under the sun, and every generation must re-learn the lessons of its predecessors.

    2. DrXym Silver badge

      Re: So Many Package Library Poisonings these Days

      There is no "guarantee", but you could perform defence in depth. Generate SBOMs and check for vulns. Use a proxy for fetching deps since some of those also scan for vulns and policies can be set up to distrust packages based on rules. Also use audit & socket scan commands in your cargo / npm / pip periodically and also from CICD. If you use Renovate then set that up likewise.

      On top of that you could security harden the build system, e.g. containerize tools so they can access the proxy but "phone home" code in postinstall / build.rs shenanigans could be prevented.

      And these days you could also throw AI at the package dir from time to time to see if it can detect malicious code.

      1. Claptrap314 Silver badge

        Re: So Many Package Library Poisonings these Days

        "And these days you could also throw AI at the package dir from time to time to see if it can detect malicious code."

        I thought the goal was to reduce security incidents, not create entirely new classes of them.

  4. Anonymous Coward
    Anonymous Coward

    Consider any program that pulls hundreds of micro-dependencies from dependency aggregation systems (e.g. NPM/crates.io/PIP/CPAN/etc) as unsafe.

    1. Anonymous Coward
      Anonymous Coward

      Esp. When you really have absolutely no idea fully what they do when they are genuine or benign ….. Inc tricking telemetry home ….. before you even get to malicious or poisoned.

      It’s reckless, multipled by places like GitHub being a security and reliability cluster-fuck.

    2. druck Silver badge

      The small driver and GUI to control fans and keyboard LEDs on ASUS laptops is about 20,000 lines of Rust but pulls down an gigabyte of crates when it builds, which is frankly obscene.

      Who is going to notice another few megabytes of malware amongst all that crap.

  5. Claptrap314 Silver badge

    This again?

    Well, it's been at least a year since I mapped the proper architecture.

    1) You run your own "mirror" of any source repository. Deletions are logged, not honored. Overwrites are likewise stored for analysis.

    2) You have a "world builder" system that takes packages from the "mirror" and puts them into the source server for the build system. This can rewrite package names & versions. The build system only sees what the company has decided it should see.

    3) At build time, the build system is completely isolated. Any attempts to access the outside are security incidents.

    We complain about the critical infrastructure folks, but this is pretty much at that same level, if on a smaller scale.

    1. Anonymous Coward
      Anonymous Coward

      Re: This again?

      I guess like a Volvo EX90 ‘safest car we have ever made’ …. You can drive Rust off the cliff too (esp. if a repository has been compromised and poisoned).

      Who’d a thunk.

  6. jiho

    So much cargo. So much compiler.

    Rust seemed like such a simple, small and harmless language.

  7. jiho

    locked the account while attempting to contact them

    Did they ever contact them?

  8. jiho

    Your machine may be compromised, but at least your memory is safe.

    1. Ace2
    2. Eric 9001 Bronze badge
      Black Helicopters

      Reminder that most bugs are logic errors and logic errors are memory safe.

      Rust has the interesting property of taking 12-160x lines to do the same thing in C (I measured) - thus "rewriting in rust", has the wonderful tradeoff of increasing the amounts of bugs by 12-160x, to save having to correct the last 10-30% of remaining bugs in well developed, mature C codebases, that have had almost all of the logic errors worked out, with a few remaining memory errors to fix.

      The goal of a "rust rewrite" in many cases seems to consist of taking GPLv3-or-later C codebases, cloning the functionality wrong (adding TOCTOU bugs for example), or blatantly translating them to rust, slapping on MIT expat and then encouraging making the software proprietary.

      Due to all the work required to do simple tasks, it seems rust crates are used to do everything and rust crates are not just full of logic errors - now it's been noticed that those are also full of malware.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon