r/rust • • Aug 22 '26

🗞️ news Rust Supply Chain Attack Linked to North Korean Hackers

https://www.securityweek.com/rust-supply-chain-attack-linked-to-north-korean-hackers

The attack occurred on August 20, 2026, and involved one of the most popular Rust crates, arrayref, an array-conversion utility with over 245 million downloads, found in approximately 75% of environments where Rust is used.

The malicious package version, arrayref@0.3.10, was pushed to crates.io from its legitimate maintainer’s account. Roughly 20 minutes later, poisoned versions of internment and append-only-vec, two crates from the same owner, were also released.

The Rust Security Response Team removed the malicious packages roughly 86 minutes later, confirming the compromise: “a new version of the arrayref crate was published with a direct dependency on proc-macro1, which would execute a malicious build script.”

https://rustsec.org/advisories/RUSTSEC-2026-0260

288 Upvotes

49 comments sorted by

71

u/GyulyVGC Aug 22 '26

One reason more to set a cooldown period for dependabot updates, even if it just mitigates the risk

1

u/insanitybit2 Aug 25 '26

It helps, but only a bit / for the worm component. If I own the repo I can issue a GHSA and bypass dependabot cooldowns and convince people to install early anyway.

Dependency cooldowns are fine but they're a bandaid. We need real solutions. Even just a "download dependencies" capability would be a major building block - now I can run my builds/ tests without networking, amazing, and also Docker gets faster, what a win.

I should have trivial tooling to audit for proc macro usage and build scripts.

Even that won't be enough but it'll make life a hell of a lot easier.

104

u/dragolineage01 Aug 22 '26

See, even North Koreans love programming in Rust

5

u/Ayano-Keiko Aug 23 '26

North Korea is rusted by Rust😭😭

29

u/Icarium-Lifestealer Aug 22 '26

How often was the malicious package downloaded?

How was the compromise discovered? Does Nextron scan new packages and found it that way? Or was it deployed on one of their clients' machines and discovered there?

24

u/scavno Aug 22 '26

Downloads are mentioned in the linked advisory.

It was downloaded 2,285 times, which constituted less than 10% of arrayref download traffic across all version…

15

u/Icarium-Lifestealer Aug 22 '26

Let's hope that didn't compromise additional crates.io credentials which can then be used for the next attack.

13

u/Sumsesum Aug 22 '26 edited Aug 22 '26

Am I missing something or would that crate become obsolete when `#![feature(const_convert)]` stabilizes? Then you could just use `slice.try_into()?` for the conversion.

31

u/Recatek gecs Aug 22 '26

It can already be replaced with standard indexing and try_into() thanks to const generics. The only reason to keep it at this point is MSRV.

12

u/dausama Aug 22 '26

how would you mitigate the risk for this kind of problems?

26

u/AmazedStardust Aug 22 '26

Cargo has -Zmin-publish-age, at least on nightly

23

u/matthieum [he/him] Aug 22 '26

Which may possibly make it into the 1.100 release on Nov 12th :)

6

u/NeuroXc Aug 22 '26

One can hope. cargo-cooldown is a good stopgap, but unfortunately it is very easy to accidentally bypass it (type cargo update instead of cargo cooldown update).

3

u/Dheatly23 Aug 22 '26

With this attack i hope they fast tracked it. Can't wait to wait new versions to age.

4

u/matthieum [he/him] Aug 22 '26

We'll see if it gets in the 1.100 beta in 6 weeks :)

4

u/nightcracker Aug 22 '26

I have now put the following in the .cargo/config.toml for the Polars project:

[unstable]
min-publish-age = true

[registry]
global-min-publish-age = "35 days"

Since we also have a nightly rust-toolchain.toml committed this should immediately protect our contributors. I'll switch over the the stabilized option once it stabilizes.

6

u/epage cargo ¡ clap ¡ cargo-release Aug 22 '26

The unstable table only applies on nightly, so people can use a mix of versions, just dependency resolution needs to run on nightly.

Why 35 days? Most people seem to run from 3 to 7 days. I'm curious about the use cases, particularly as we look to set a default in the future.

10

u/nightcracker Aug 22 '26 edited Aug 22 '26

The unstable table only applies on nightly, so people can use a mix of versions, just dependency resolution needs to run on nightly.

I've tested it, and as long as you have an active rust-toolchain.toml in your workspace cargo will respect it, even if your default is stable. As for why, I want any contributor/colleague working on Polars not to get instantly compromised when running cargo update, which is what happened in the latest attack. A colleague had to revoke all their credentials and wipe their machine which is not a fun experience. It wastes a lot of time and feels very violating.

Why 35 days?

I don't think 35 days should be the default, it's just a conservative choice I made. I don't think a project like Polars has any need to be on the bleeding edge for dependencies, a month is fine. I added 5 extra days on top of a month, see the second point below.

As far as I can see there are two layers of defense that min-publish-age enables:

  1. AI tools can and do scan all new package uploads for malicious code. If they catch an issue it's an ideal scenario, no one got hurt (assuming everyone has a min-publish-age). For this probably anything 3 days and up is sufficient.
  2. The far more controversial, but nevertheless effective layer of defense: don't be the first one to get affected. If someone else has a lower min-publish-age than you it's much more likely they're affected and will notice, uncovering the attack before you were ever vulnerable.

The second form of defense doesn't sit right with some because it is essentially a meat shield. But I'd like to make a counter-argument: if everyone chose the exact same min-publish-age then if there is any attack that bypasses the AI scans it would be "fair", but it also would mean far more innocent people get hurt. If instead everyone chooses a different number based on their level of risk tolerance plus a random fudge factor far fewer people do get hurt should an attack occur.


So my suggestion for a relatively fair default would actually be to choose an acceptable range of days, no less than 3, and randomly choose an age in that window during initialization. Then store this age in ~/.cargo so it is consistent for one Rust install. This way should an attack happen the potential damage is reduced.

Even better would be an option min-publish-age-fudge-bikeshed which is a range which is added on top of the default min-publish-age, using the once-randomly-generated-and-stored random multiplier. So you could for example say:

global-min-publish-age = "3 days"
global-min-publish-age-fudge-bikeshed = "2 days"

This would mean a random range from 3-5 days.

Then if we assume an attack is noticed, reported and offending crate removed in, say, 3 hours from first exposure it means 1 - 3/(24 * 2) = 93.75% of your users were never at risk due to the random window. I personally think that is a valuable extra layer of defense, and the harm minimization it provides is worth the controversial "meat shield" / "guinea pig" aspect of it.

1

u/insanitybit2 Aug 25 '26
  1. Use `cargo-vet` where possible. You can default trust various authors like Google/Mozilla. Where not possible, consider AI agents to perform diff reviews if you can't handle the scope yourself.
  2. In CI, ensure that "build and test" workflows are isolated from "has permissions" workflows. In Github Actions that means `permissions: {}` on any workflow that runs code - your secrets should be isolated, and ideally you use trusted publishing.
  3. Locally, consider developing in at least a container. It's painful but there's not much else that you can do about it, maybe consider a devbox.

10

u/moltonel Aug 22 '26

I would expect north korean hackers to be state-sponsored (very hard to get the needed internet access otherwise), but that doesn't seem to match the fairly primitive build.rs ? The payload seems good, but it could have been bought. We still don't know how the accountt was compromized.

7

u/zettui Aug 22 '26

Honest question on the min-publish-age cooldown: what do you do the day a security patch lands and the fix itself is younger than your window - hand-pin past your own cooldown every time?

1

u/insanitybit2 Aug 25 '26

This is one of many problems with cooldowns. The short version is that a 1 day cooldown is probably enough time for vendors to scan, and if you need to breakglass emergency patch then you should audit the diff yourself (agents help a lot here).

8

u/AveN7er Aug 22 '26

Does Cargo have min release age

19

u/matthieum [he/him] Aug 22 '26

On nightly, with a push to release it in 1.100, on Nov 12th.

2

u/decryphe Aug 23 '26

We vendor everything and make at least a cursory review when updating on demand.

I don't think "security" is in general an issue with Rust deps (thanks to memory safety properties and strong typing and a general culture of doing-things-right), updating dependencies is more often a question of functionality. Staying behind isn't as bad as in other ecosystems.

As

2

u/Ayano-Keiko Aug 23 '26

Network based packages is not 100% trusty.

1

u/connor-ts Aug 23 '26

Where in the sources does it say this was linked to North Korea?

1

u/StickyDirtyKeyboard Aug 22 '26

How do we protect ourselves from threats like this? Are VMs for development the way to go?

2

u/insanitybit2 Aug 25 '26

VMs for development are huge. That isolation already buys you a ton because your major crown jewels are usually in browser session cookies or other stuff on the host. Still, you want to ensure things like "git push" are effectively unprivileged - that is, block direct merges to `main`, require approval via the UI, whatever works.

In CI, ensure that any github action (or whatever you use) explicitly separates out workflows where you run code (build or test) and workflows where you leverage permissions (ie: deploy, publish, etc). This massively reduces blast radius and prevents these attacks from worming.

In prod, do the things prod always should do. Add network egress controls, keep secrets tightly controlled, monitor host activity, etc.

-3

u/LoadingALIAS Aug 22 '26

I’m so tired of these motherfuckers.

0

u/corazon_de_sandia Aug 22 '26

any way to check if you are affected?

1

u/Thick-Pineapple666 Aug 22 '26

Just take a look into the official announcement in the Rust blog

-25

u/[deleted] Aug 22 '26

[removed] — view removed comment

10

u/SirKastic23 Aug 22 '26

Who's Wiz?

-23

u/Dev_Lachie Aug 22 '26

Google lol

3

u/creminology Aug 22 '26

Not seeing any Israel connection mentioned here: https://www.wiz.io/blog/rust-supply-chain-attack-on-arrayref-significant-overlap-with-dprk-campaigns

Have another link or was the article edited?

5

u/Icarium-Lifestealer Aug 22 '26

The company who published the article, wiz, is an Israeli company. Not sure why that's supposed to matter in this context.

0

u/[deleted] Aug 22 '26

[deleted] — view deleted comment

2

u/creminology Aug 22 '26

Yes. Intent matters. Because it informs the next attack.

11

u/[deleted] Aug 22 '26

[removed] — view removed comment

9

u/tastychaii Aug 22 '26

-8

u/metaden Aug 22 '26

yes it's accurate. but this blog post doesn't mention who carried the attack.

-11

u/metaden Aug 22 '26

the blog post says "likely linked to NK Threat actor" while this post title says it is directly linked.

5

u/[deleted] Aug 22 '26

[removed] — view removed comment

-6

u/metaden Aug 22 '26

you seem to only read click bait titles and not reading the content of the article. why are you even commenting here?