LinuxXII · Repository Security and Supply ChainSupply chain
Mitigating curl | bash and other supply-chain footguns
What you'll learn
- Explain why `curl | bash` is dangerous
- Distinguish safe and unsafe install patterns
- Build a host-bootstrap procedure that does not pipe to a shell
- Recognise the social engineering that produces this pattern
Prerequisites
Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09
The curl | bash pattern is the most common supply-chain
footgun in modern Linux operations. It downloads arbitrary code
from a URL and executes it immediately — with no verification, no
audit, no rollback.
The pattern
$ curl https://get.example.com/install.sh | sudo bash...Illustrative output
Why this is dangerous
| Concern | Why it matters |
|---|---|
| URL hijacking | A DNS hijack, BGP hijack, or compromised web server substitutes a malicious script |
| TLS is not enough | TLS verifies the certificate, not the script. The script could be legitimate today and replaced tomorrow |
| No checksum verification | The host runs whatever is at the URL; no SHA256, no GPG signature |
| No rollback | The script can do anything; reverting requires understanding what it did |
| No audit | The script is not in the host’s package database; the host’s actual configuration is invisible |
| Root privileges | Most curl-piped-to-sudo-bash invocations run as root |
$ curl -fsSL https://get.example.com/install.sh | sudo bash -s -- --version 1.2.3...Illustrative output
The safe pattern
Download first, verify, then execute. Three steps instead of one.
$ curl -fsSL -o /tmp/install.sh https://get.example.com/install.sh; curl -fsSL -o /tmp/install.sh.sig https://get.example.com/install.sh.sig; gpg --verify /tmp/install.sh.sig /tmp/install.sh; sudo bash /tmp/install.sh --version 1.2.3; rm /tmp/install.sh /tmp/install.sh.sig...Illustrative output
| Step | What it protects against |
|---|---|
| Download to file | Inspect the script before executing |
| Verify checksum | Detect tampering in transit |
| Verify GPG signature | Confirm the script was signed by the trusted key |
| Execute locally | No piping, no re-download during execution |
| Clean up | No persistent /tmp file after install |
Build-time verification
For internal scripts and configuration, the discipline is to package them with the host’s distribution package manager:
- In-house .deb/.rpm — package the script as a Debian or RPM package; distribute via the host’s local mirror.
- Configuration management — Ansible, Puppet, or Chef apply the script as part of the host’s declared configuration.
Either approach gives the host’s audit trail every artefact.
in-toto and SLSA
For organisations with mature supply chains, the in-toto framework and SLSA (Supply chain Levels for Software Artifacts) provide attestation:
- SLSA Level 1 — provenance documented; builds automated.
- SLSA Level 2 — signed provenance; build platform hardened.
- SLSA Level 3 — provenance verified end-to-end; build platform hardened against specific threats.
- SLSA Level 4 — two-party review; hermetic reproducible builds.
Each level adds guarantees about how the package was built. Production hosts that consume packages from SLSA Level 3+ vendors can verify provenance cryptographically.
Knowledge check
Knowledge check · 3 questions
Q1. Why is `curl | sudo bash` dangerous?
Q2. Verifying a checksum before running a downloaded script is sufficient.
Q3. Which of the following are correct defences against the curl | bash pattern? Select all that apply.
Passing score: 75%. Answers are checked in this browser.