⚠ curl | bash is risky

A safer
curl | bash

Drop-in replacement for bash in the curl | bash pattern. Buffers the full script, enforces strict mode, analyses for risks, and asks before running — without adding friction to your workflow.

Before

$ curl -fsSL https://example.com/install.sh | bash

After

$ curl -fsSL https://example.com/install.sh | safesh

Install via go:

$ go install github.com/safesh/safesh/cmd/safesh@latest

What it looks like

Running an installer script through safesh:

$ curl -fsSL https://example.com/install.sh | safesh safesh fetched 2.4 KB · sha256 verified ⚠ 3 findings privilege line 14 sudo apt-get install -y build-essential network line 28 curl https://releases.example.com/v2.1.0/binary persistenceline 41 echo 'export PATH=...' >> ~/.bashrc Run this script? [y/N] y ✓ exited 0 · history saved to ~/.local/share/safesh/history/

How it protects you

Seven guarantees, zero configuration required.

Full buffering

Reads the entire script before executing any of it. A dropped connection never leaves you half-installed.

🔒

Strict mode

Prepends set -euo pipefail to catch unset variables and failed commands.

🔍

Static analysis

Walks the AST to surface privilege escalation, destructive ops, obfuscation, persistence, and more.

🛡

Integrity checking

Auto-discovers sibling .sha256 files or accepts an explicit hash to verify before running.

📋

Execution history

Every run — including dry runs and aborted ones — is logged with script, findings, and exit status.

🧹

Environment isolation

Strips the environment to a safe baseline. Only PATH, HOME, and a few others pass through.

Finding categories

All findings are reported with line numbers before you decide whether to proceed.

Category What it flags
execution-integrity Missing set -e / -u / -o pipefail
destructive rm -rf, dd, mkfs, truncation
privilege sudo, su, pkexec, doas
persistence Shell profile writes, cron jobs, systemd unit installs
network Outbound curl / wget calls with resolved domains
obfuscation eval, base64-decode-and-exec chains
execution-chain Nested curl | bash inside the script
Unsuspicious ≠ safe. A script that passes all checks is one we couldn't find anything wrong with — not one that is guaranteed harmless. safesh is one layer of defense, not a security guarantee. Use it. Keep your eyes open.