SECURITY ENGINEERING · PART 9 · DEVSECOPS AND SUPPLY CHAIN · SUPPLY CHAIN · 128 OF 229

Supply Chain Attacks: Typosquatting to xz-utils

Why attack one company when you can compromise a dependency thousands of companies use? This episode covers software supply chain attacks: typosquatting and dependency confusion, compromised maintainers and malicious updates (SolarWinds, the xz-utils backdoor), build-system compromise, and the layered defences, pinning, verification, provenance, least privilege and detection, that make them much harder to pull off.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19
  19. 20
  20. 21
  21. 22
  22. 23
  23. 24
  24. 25
  25. 26
  26. 27
  27. 28
  28. 29
  29. 30
  30. 31
  31. 32
  32. 33
  33. 34
  34. 35
  35. 36
  36. 37
  37. 38
  38. 39
  39. 40
  40. 41
  41. 42
  42. 43
  43. 44
  44. 45
  45. 46
  46. 47
  47. 48
  48. 49
  49. 50
  50. 51
  51. 52
  52. 53
  53. 54
  54. 55
  55. 56
  56. 57
  57. 58
  58. 59
  59. 60
  60. 61
  61. 62
  62. 63
  63. 64
  64. 106
  65. 107
  66. 108
  67. 109
  68. 110
  69. 111
  70. 112
  71. 113
  72. 114
  73. 115
  74. 116
  75. 117
  76. 118
  77. 119
  78. 120
  79. 121
  80. 122
  81. 123
  82. 124
  83. 125
  84. 126
  85. 127
  86. 128
  87. 129
  88. 130
  89. 131
  90. 132
  91. 133
  92. 134
  93. 135
  94. 136
  95. 137
  96. 138
  97. 139
  98. 140
  99. 141
  100. 142
  101. 143
  102. 144
1 / 10

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Poison one dependency or build, hit thousands
  • typosquatting, confusion, hijacked maintainers
  • layer the defences

Notes

The leverage

The leverage is enormous. Your application trusts its dependencies completely: their code runs with your code's privileges. Those dependencies trust theirs, transitively, many levels deep. So compromising one popular package reaches everyone who uses it, directly or indirectly. The same trust that makes open source work, reusing millions of lines you never read, is the attack surface. Supply-chain defence is about not trusting blindly the code you did not write.

Why the supply chain
  • your app trusts its deps completely; they run your code
  • deps trust their deps (transitive), levels deep
  • compromise one popular package and you reach all its users
  • the same trust that makes open source work is the attack surface

Typosquat and confusion

Two attacks trick the installer into fetching the wrong package. Typosquatting publishes a malicious package with a name close to a real one, so a typo or copy-paste installs it. Dependency confusion is cleverer: an attacker publishes a public package with the same name as your internal private one but a higher version, and the package manager, preferring the higher version, pulls the attacker's from the public registry. Both have hit real companies, and both often run a malicious install script.

Package name tricks
  • typosquatting: a malicious package named like a real one (reqeusts vs requests)
  • dependency confusion: a public package shadows your private one with a higher version
  • malicious install scripts run on install
  • both have hit real companies at scale

Compromised maintainers

The most dangerous variant is when a genuine, trusted package ships a malicious version. A maintainer account gets phished or hijacked, and a poisoned release goes out to everyone who updates. The xz-utils case in twenty twenty four was chilling: an attacker spent months earning maintainer trust on a core compression library, then slipped in a backdoor that nearly reached mainstream Linux before one engineer noticed a tiny performance anomaly. It shows how patient these attacks are, and how close they come.

When the real package turns
  • a maintainer account is phished or hijacked
  • or a maintainer is socially engineered over months
  • a malicious version ships to everyone who updates
  • xz-utils (2024): a backdoor almost reached mainstream Linux via a trusted maintainer

Build-system compromise

Attackers also target the build system itself. In the SolarWinds attack of twenty twenty, they compromised the build pipeline, not the source, and inserted malicious code during the build. The result shipped as an officially signed update to around eighteen thousand organisations, because every normal check passed: the source looked clean and the signature was valid. This is why build integrity and provenance, the SLSA framework from last episode, matter: they protect the step between source and artifact.

SolarWinds-style attacks
  • compromise the build system, not the source
  • malicious code inserted during the build
  • ships signed and "legitimate" to all SolarWinds (2020): reached ~18,000 organisations
  • this is why build integrity (SLSA) matters

The defences

No single control stops supply-chain attacks, so you layer the tools from this part. Pin exact versions with a lockfile, and add a cooldown so brand-new releases are not adopted instantly. Verify signatures and provenance at deploy. Use an internal proxy registry and scope private package names so confusion cannot shadow them. Run dependency and secret scanning in CI. Give build tokens least privilege and isolate builds so a compromise cannot spread. And monitor installs and runtime behaviour.

Defence in depth
  • pin exact versions; use a lockfile and a cooldown
  • verify signatures and provenance (SLSA, ep 6)
  • use an internal proxy/registry; block confusion by scoping private names
  • SCA + secret scanning in CI
  • least privilege for build tokens; isolate builds
  • monitor installs and behaviour

The human layer

The xz-utils case teaches that not every defence is technical. Some attacks are patient and social: an attacker slowly becomes a trusted maintainer. So vet critical dependencies for maintainer health, watch for suspicious handoffs to a new, unknown maintainer, and be wary of a critical library with a single exhausted maintainer, a common pattern. Reduce your dependency count, support the maintainers you rely on, and have an incident plan for a poisoned dependency.

Beyond tooling
  • vet critical dependencies: maintainer health, activity, single-maintainer risk
  • watch for maintainer handoffs and sudden new contributors
  • reduce dependency count; fewer deps, smaller surface
  • support the maintainers you rely on have an incident plan for a poisoned dependency

Common mistakes

Mistakes that leave you exposed. Floating version ranges with no lockfile or cooldown, so a malicious release is pulled automatically. Private package names that are not scoped, inviting dependency confusion. No verification of signatures or provenance, so a swapped artifact is accepted. Build tokens with broad permissions, so a build compromise spreads far. Pulling in any package without any vetting of its maintainers or health. And no incident plan for the day a dependency you depend on is found to be backdoored.

Avoid these
  • floating versions, no lockfile or cooldown
  • private package names not scoped (confusion risk)
  • no signature or provenance verification
  • build tokens with broad permissions
  • trusting any package without vetting
  • no plan for a poisoned dep

Say it like this

In the interview: there is no single fix, so I layer. I pin exact versions with lockfiles and a cooldown, verify signatures and provenance at deploy, use an internal proxy registry and scope private names against dependency confusion, and run dependency and secret scanning in CI. I give build tokens least privilege and isolate builds so a pipeline compromise cannot spread. And because attacks like xz-utils are social, I vet critical dependencies and their maintainers.

In the interview
  • "Layer it: pin and lock with a cooldown, verify signatures and provenance, proxy registries
  • and scope private names against
  • confusion, SCA and secret
  • scanning, least-privilege
  • isolated builds, and monitoring. Plus vet critical
  • deps and their maintainers.
  • xz-utils and SolarWinds show why."

Interview questions

Q1What is a software supply chain attack?

An attack that compromises a component, dependency, build system or distribution channel that many organisations trust, so that malicious code reaches all of their downstream consumers at once, rather than attacking each target directly.

Q2What is typosquatting in package registries?

Publishing a malicious package with a name very similar to a popular one, so that a typo or mistaken install pulls the attacker's package. Such packages often run malicious scripts at install time to steal secrets or gain execution.

Q3What is dependency confusion?

An attack where a public package is published with the same name as an organisation's internal private package but a higher version number, so the package manager fetches the attacker's public version instead of the intended private one. Scoping and resolving private names from a controlled registry prevents it.

Q4What happened in the xz-utils backdoor?

In 2024, an attacker spent months gaining maintainer trust on the widely used xz compression library and inserted a backdoor that nearly reached mainstream Linux distributions before being caught by an engineer investigating a small performance anomaly. It exemplifies patient, social supply-chain compromise.

Q5What was the SolarWinds attack?

A 2020 attack in which adversaries compromised SolarWinds' build system and inserted malicious code during the build of its Orion product. The result shipped as a legitimately signed update to around 18,000 organisations, illustrating build-system compromise.

Q6How do you defend against supply chain attacks?

With layered controls: pin and lock dependency versions with a cooldown, verify signatures and provenance, use proxy registries and scoped private names, run SCA and secret scanning, apply least privilege and isolation to builds, monitor behaviour, and vet critical dependencies and maintainers.

Q7Why does build integrity (SLSA) matter for supply chain security?

Because attacks like SolarWinds insert malicious code during the build, after clean source and before signing. Hardened, isolated builds with unforgeable provenance let consumers verify that an artifact was genuinely built from the expected source, closing that gap.

Q8Why are single-maintainer dependencies a risk?

A critical library maintained by one overburdened person is easier to compromise through account takeover, social engineering or a project handoff to an untrusted new maintainer. Vetting maintainer health and reducing reliance on such dependencies lowers the risk.