Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Curl to Bash
Cyber Security

Curl to Bash

← Back to Glossary
By NHI Mgmt Group Updated October 31, 2026 Domain: Cyber Security

Curl to Bash is a software delivery pattern where a script is downloaded from the internet and executed immediately in a shell. It is convenient, but risky, because the downloading step and the execution step happen with little or no validation. In CI environments, that can turn a supply chain compromise into credential theft.

What Curl to Bash Means in Practice

Curl to Bash is not just a convenience pattern, it is a trust decision. The download and execution steps are collapsed into one action, so the shell runs code before a person or pipeline has meaningfully inspected it. That makes the pattern attractive for demos and automation, but fragile when the source, transport, or script contents are not tightly controlled.

The main security issue is that the shell becomes an execution boundary with very little decision time. If the remote content changes unexpectedly, the command line will faithfully execute it, which is why curl to bash is treated as a high-risk software delivery shortcut rather than a normal installation method.

Why It Is Dangerous in Delivery Pipelines

In CI/CD, this pattern can turn a compromised upstream asset into immediate code execution inside build or deployment infrastructure. That matters because pipeline runners often hold secrets, signing material, cloud credentials, package publishing rights, or access to downstream systems. When a script is executed straight from the network, the compromise path is often shorter than the defender’s review path.

It also weakens provenance. A script fetched at runtime may bypass code review, package signing checks, artifact integrity verification, and change control. If the remote endpoint, redirect chain, CDN object, or embedded dependency is tampered with, the risk is not limited to the script itself, it extends to whatever the script can reach after execution.

How Organisations Reduce Exposure

The first question is whether the organisation can avoid live execution altogether. A safer pattern is to fetch the script, inspect it, pin the source, and run it only after verification. For broader supply-chain context, the SLSA model is useful because it shifts attention toward provenance, integrity, and controlled build inputs rather than blind runtime trust.

Organisations should also use trusted repositories, internal mirrors, checksum validation, signed releases, and restricted egress from build workers where practical. If a script must be downloaded during automation, the operational question is not whether it is convenient, but whether the source, content, and execution environment are all sufficiently governed to make immediate execution acceptable.

Detection, Containment, and Post-Execution Review

Once this pattern has been used, defenders should assume the script may have run with the current user’s privileges and with whatever network or secret access was available at that moment. Review shell history, CI job logs, endpoint process trees, temporary files, outbound connections, and any artifact upload or package publish activity triggered during execution.

For investigation and control mapping, the MITRE ATT&CK Enterprise Matrix helps frame likely follow-on behaviour such as credential access, discovery, persistence, and lateral movement. If the script accessed secrets or session material, rotate the exposed material and confirm that downstream systems did not accept any newly created tokens, keys, or automation credentials.

Where script-driven compromise is a recurring concern, the NIST SP 800-53 Rev 5 Security and Privacy Controls catalog is relevant because it ties together access control, auditability, configuration management, and system integrity expectations for environments that run automated code.

Safer Ways to Achieve the Same Outcome

Practitioners usually want speed, reproducibility, or one-line onboarding, not the risk itself. A safer design is to distribute install scripts through versioned artifacts, source-controlled release assets, package managers, or controlled internal tooling, so execution is separated from acquisition and can be reviewed, logged, and governed.

If the command is used at all, treat it as an exception path with clear ownership. The script should be readable, pinned to a known version, validated before execution, and run in an environment with the minimum privileges needed for the task. That keeps the convenience of automation without normalising unaudited remote code execution.

Risk and Threat Considerations

Curl to Bash is risky because it compresses trust, download, and execution into a single step. That creates a direct attack path from upstream compromise to local code execution, and in CI environments the blast radius can include secrets, signing capability, and deployment access.

Failure mechanism: An attacker compromises the hosting source, transport path, redirect chain, or script content, then waits for an automated job or user to execute the fetched payload without meaningful inspection.

Impact: The script can steal credentials, modify build outputs, drop persistence, or pivot into other systems that trust the affected runner or workstation.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK addresses the attack and risk surface, while SLSA and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
SLSASupply-chain Levels for Software ArtifactsCurl to Bash is a provenance and integrity problem for fetched code
Recommendation — Prefer verified artifacts and provenance controls before running downloaded scripts.
MITRE ATT&CKEnterprise MatrixImmediate script execution can enable credential access and follow-on attack behavior
Recommendation — Map resulting behavior to ATT&CK and hunt for credential access, persistence, and lateral movement.
NIST SP 800-53 Rev 5SI-7 — Software, Firmware, and Information IntegrityDownloaded scripts need integrity checks before execution
Recommendation — Apply SI-7 to verify script integrity before it is executed in automation.

Practitioner Guidance

Why practitioners should care: The control problem is not shell syntax, it is trust establishment. If the command is used in onboarding, build automation, or emergency operations, the organisation is implicitly accepting runtime execution of remote content as a security boundary.

Common misunderstanding: Setting strict shell options does not solve the core issue, because the main danger is not only script correctness, but unverified code provenance and execution authority.

Practitioner takeaway: Treat curl to Bash as an exception pattern that deserves explicit approval, verification, and compensating controls, not as a default installation mechanism.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 31, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org