Skip to main content
RunBook Academy

LinuxXII · Repository Security and Supply ChainSupply chain

Mitigating curl | bash and other supply-chain footguns

Intermediate⏱ ~8 minbashcurlsha256sumgpg

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

Not yet marked complete on this device.

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

Data-loss riskcurl | bash
$ curl https://get.example.com/install.sh | sudo bash
...

Illustrative output

Why this is dangerous

ConcernWhy it matters
URL hijackingA DNS hijack, BGP hijack, or compromised web server substitutes a malicious script
TLS is not enoughTLS verifies the certificate, not the script. The script could be legitimate today and replaced tomorrow
No checksum verificationThe host runs whatever is at the URL; no SHA256, no GPG signature
No rollbackThe script can do anything; reverting requires understanding what it did
No auditThe script is not in the host’s package database; the host’s actual configuration is invisible
Root privilegesMost curl-piped-to-sudo-bash invocations run as root
Data-loss riskcurl | bash with arguments
$ 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.

Configuration changesafe download
$ 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

StepWhat it protects against
Download to fileInspect the script before executing
Verify checksumDetect tampering in transit
Verify GPG signatureConfirm the script was signed by the trusted key
Execute locallyNo piping, no re-download during execution
Clean upNo 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

  1. Q1. Why is `curl | sudo bash` dangerous?

  2. Q2. Verifying a checksum before running a downloaded script is sufficient.

  3. 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.