Real Incidents: event-stream to xz-utils
The controls in this course exist because each of them would have stopped, or shortened, a real attack. Five incidents cover the whole threat model. The dates and details below are from the public post-mortems and advisories; read them in that order and the pattern is clear: attackers moved from single packages to build systems, and from stolen credentials to patient social engineering.
| When (discovered) | Incident | Link in the chain | Threat |
|---|---|---|---|
| Nov 2018 | event-stream (npm) | a maintainer handed the package to a stranger | compromised maintainer, D |
| Dec 2020 | SolarWinds Orion (SUNBURST) | malware in the vendor's build system | compromised build, E |
| Apr 2021 | Codecov Bash Uploader | a modified script on the vendor's download server | modified distribution, F/G |
| Mar 2023 | 3CX Desktop App | a compromised developer machine, via another supply-chain attack | compromised build / developer, E |
| Mar 2024 | xz-utils (CVE-2024-3094) | a co-maintainer built trust for two years, then shipped a backdoor | compromised maintainer, A/C |
event-stream (2018): the handed-over package
event-stream was a popular npm package with millions of weekly downloads whose original author no longer maintained it. In September 2018 he gave publish rights to a volunteer who had offered to help. The new maintainer added a dependency, flatmap-stream, whose version 0.1.1 contained an encrypted payload. A user noticed it in November 2018.
The payload was targeted: it used the description of the application being built as the decryption key, so it only decrypted inside the build of the Copay bitcoin wallet, where it tried to steal wallet keys. Every other project installed the malicious code and nothing visible happened. The model below shows why such a payload survives casual review and sandbox testing.
import hashlib
def keystream(secret: str, n: int) -> bytes:
out = b""
counter = 0
while len(out) < n:
out += hashlib.sha256(f"{secret}:{counter}".encode()).digest()
counter += 1
return out[:n]
def xor(data: bytes, key: bytes) -> bytes:
return bytes(a ^ b for a, b in zip(data, key))
# The attacker encrypts the payload with the target app's description.
target = "A Secure Bitcoin Wallet"
payload = b"steal_wallet_keys()"
blob = xor(payload, keystream(target, len(payload)))
# The innocent-looking dependency tries the *current* app's description at install time.
for app in ["My todo list", "Express web server", "A Secure Bitcoin Wallet"]:
decoded = xor(blob, keystream(app, len(blob)))
ok = decoded.isascii() and decoded.endswith(b"()")
print(f"{app:24} -> {'RUNS PAYLOAD' if ok else 'garbage, does nothing'}")My todo list -> garbage, does nothing
Express web server -> garbage, does nothing
A Secure Bitcoin Wallet -> RUNS PAYLOAD
Lessons: a maintainer change is a security event; a new transitive dependency in a patch release deserves a look; and an SBOM diff between two builds would have shown flatmap-stream appearing.
SolarWinds Orion (2020): the build system
In December 2020 FireEye (later Mandiant) disclosed that trojanized updates of SolarWinds' Orion network-monitoring software had been shipped to customers. Attackers had access to SolarWinds' build environment and planted a tool, later named SUNSPOT, that watched for Orion builds and swapped a source file during compilation, then restored it. The repository was clean, the build output was not, and the result was signed with SolarWinds' legitimate code-signing certificate. The backdoored versions were released between March and June 2020 and were installed by roughly 18,000 customers, a much smaller number of whom were then actively exploited, including US government agencies.
Lessons: a signature proves who released it, not what source it came from. Build integrity needs isolated, ephemeral builders, provenance that ties the binary to a source commit, and ideally an independent reproducible rebuild that would produce a different hash from the tampered one.
Codecov (2021): curl | bash
Codecov's "Bash Uploader" was a script many CI pipelines downloaded and executed on every run (curl -s https://codecov.io/bash | bash). Starting at the end of January 2021, an attacker who had extracted a credential from Codecov's Docker image build process modified the script on Codecov's servers to send the CI environment, which usually contains secrets and tokens, to an attacker-controlled server. A customer noticed because the script's SHA did not match the one published on GitHub; Codecov disclosed in April 2021.
Lessons: never execute unpinned remote code in CI; pin downloads by hash and check them; give CI jobs the minimum secrets they need. Both the attack and the detection were about one hash.
3CX (2023): a supply-chain attack inside a supply-chain attack
In late March 2023 security vendors detected that the signed 3CX Desktop App (a softphone used by many businesses) was contacting malicious infrastructure. Mandiant's investigation found that a 3CX employee had installed a trojanized version of X_TRADER, trading software from another company that had itself been compromised earlier. From that machine the attackers moved into 3CX's build environment and shipped signed, trojanized installers for Windows and macOS. It was the first publicly documented cascading supply-chain attack, and was attributed to a North Korea-linked group.
Lessons: your build environment's supply chain includes the software on your developers' and build engineers' machines. Separate signing and build infrastructure from daily-use workstations.
xz-utils (2024): the patient maintainer
On 29 March 2024 Andres Freund, a PostgreSQL developer, reported that xz-utils 5.6.0 and 5.6.1 (released in February and March 2024) contained a backdoor (CVE-2024-3094). He noticed that SSH logins on a Debian testing machine used unusual CPU time and caused Valgrind errors.
What made it remarkable:
- The person who shipped it had contributed to the project for about two years, under the name "Jia Tan", while other accounts pressured the overworked original maintainer to add a co-maintainer.
- The malicious code was hidden in binary test files in the repository and activated by a modified build script (
build-to-host.m4) that was present only in the release tarballs, not in the Git repository. Reviewing the repository was not enough. - The backdoor targeted
sshdthroughliblzma, which some distributions link intosshdvialibsystemd, and only in Debian/RPM package builds. - It was caught in unstable and testing distributions (Debian sid, Fedora Rawhide and the Fedora 40 beta, among others) before reaching most stable releases.
Lessons: build from the source you reviewed (the repository, or tarballs reproducibly generated from it), compare release tarballs against the tag, and support maintainers. Signatures and provenance would all have been valid.
The pattern
| Incident | Would an SBOM + scan catch it? | Would signature checks catch it? | What would have helped |
|---|---|---|---|
| event-stream | no, until an advisory existed | no, the maintainer published it | review of new dependencies, SBOM diffs |
| SolarWinds | no | no, legitimately signed | isolated builds, provenance, reproducible rebuilds |
| Codecov | no | yes, if the script had been verified | hash pinning, least-privilege secrets |
| 3CX | no | no, legitimately signed | isolated build and signing infrastructure |
| xz-utils | only after disclosure | no | building from reviewed source, tarball vs tag comparison |
Scanning only finds known problems. Most of these attacks were found by a human noticing something odd. The controls in this course raise the cost of an attack and shrink the time to detect it; none makes trust unnecessary.
Go further: Supply Chain as Research: the xz-utils Case retells the xz-utils backdoor in detection terms, with three checks on a toy release.
Test yourself
Why did the event-stream payload go unnoticed in most projects that installed it?
- It was obfuscated with a packer
- It only decrypted with the target application's description as the key
- npm hid it
- It was only in the README
In the xz-utils backdoor, where was the code that activated the backdoor during the build?
- In a GitHub Actions workflow
- In a build script present only in the release tarballs, not in Git
- In the README
- In a dependency on npm
How was the Codecov uploader compromise detected?
- An antivirus alert
- A customer noticed the script's hash didn't match the published one
- Codecov's own SBOM
- A Rekor log entry