Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Fetch-and-Run Pattern
Cyber Security

Fetch-and-Run Pattern

← Back to Glossary
By NHI Mgmt Group Updated November 6, 2026 Domain: Cyber Security

The Fetch-and-Run Pattern is a technique where a script or command downloads content from a remote source and immediately executes it. It is commonly used for software installation and automation, but it also creates a narrow trust window because the fetched payload can change after review or be swapped for malicious code.

How Fetch-and-Run Changes the Trust Model

Fetch-and-run turns a one-step execution into a two-step trust decision: first trust the source, then trust the payload at the moment it is executed. That matters because the remote object can change between review and run time, the download path can be intercepted, or the command can be redirected to a different artifact than the one a human expected.

It is a common automation pattern, but the security property is weaker than running a locally reviewed and pinned artifact. The risk is not just malicious code, but also unintentional drift, transient availability problems, and hidden dependency changes that arrive with no visible review step.

Where It Shows Up in Operations

Fetch-and-run is often used in installers, bootstrap scripts, CI jobs, and ephemeral automation because it reduces manual handling. That convenience is why it persists, yet it also compresses review, provenance, and execution into a single moment where the operator has limited opportunity to validate what actually arrived.

In practice, the pattern becomes safer only when the source is tightly controlled, the artifact is pinned or integrity-checked, and the execution context is constrained. Without those guardrails, the operator is effectively executing remote content with only a brief and fragile trust window.

Why It Is Attractive to Attackers

Attackers value fetch-and-run because it gives them a path from content delivery to code execution without needing a separate install step. If they can poison DNS, compromise a hosting endpoint, replace a package, or manipulate a download URL, they may be able to turn a legitimate automation flow into an execution path for malicious code.

The pattern also lends itself to persistence and social engineering. A script that looks routine can quietly retrieve a second-stage payload, making the initial command appear harmless while the real risk is hidden in the fetched content.

How to Reduce Exposure

Reduce exposure by treating the download source, the fetched object, and the execution context as three separate things that all need control. Use provenance checks, hash or signature validation where available, pinned versions or immutable references, and network restrictions that limit where automation can fetch from.

It also helps to keep the execution environment as narrow as possible so that even if fetched code is malicious, it cannot easily reach other systems, secrets, or higher-privilege resources. Review and monitoring should focus on unexpected remote retrieval followed immediately by execution, especially in bootstrap and automation workflows.

Risk and Threat Considerations

Fetch-and-run is risky because the trust boundary is crossed at runtime, not at review time. A benign-looking command can become dangerous if the remote payload changes, the transport is intercepted, or the source is replaced with a malicious artifact before execution.

Failure mechanism: The operator approves the command shape, but the actual code that runs is fetched later and can differ from what was inspected, which defeats static review and creates a narrow but real injection window.

Impact: Compromise can lead to arbitrary code execution, malware staging, credential theft, persistence, and spread into build, deployment, or admin environments that trust the automation flow.

Standards & Framework Alignment

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

SLSA, CIS Controls v8, NIST SP 800-53 Rev 5 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
SLSASupply-chain integrityFetch-and-run depends on trusted artifact provenance and integrity at execution time.
Recommendation — Require provenance and integrity verification before executing fetched artifacts.
CIS Controls v8CIS-16 — Application Software SecurityFetch-and-run creates software delivery and execution risk that hardening and validation controls address.
Recommendation — Restrict remote code execution paths and validate downloaded content before launch.
NIST SP 800-53 Rev 5SI-7 — Software, Firmware, and Information IntegrityThis pattern hinges on verifying that fetched code has not been altered or substituted.
CM-8 — System Component InventoryKnowing where fetch-and-run occurs requires an inventory of scripts, installers, and automation components.
Recommendation — Verify software integrity before execution and reject altered payloads. Inventory bootstrap and automation components that retrieve and execute remote content.
NIST CSF 2.0PR.DS-08 — Integrity of DataThe fetched artifact must retain integrity from retrieval through execution to be trustworthy.
Recommendation — Protect artifact integrity across download, storage, and execution stages.

Practitioner Guidance

Why practitioners should care: This pattern is not inherently unsafe, but it is unsafe by default unless the source is controlled and the payload is verifiable. Treat it as a supply-chain and execution-risk decision, not just a convenience choice.

Common misunderstanding: Many teams assume that a familiar download URL or a reputable vendor page is enough. In reality, trust must extend to the content itself, the time it is fetched, and the environment that runs it.

Practitioner takeaway: Prefer pinned, integrity-checked artifacts over ad hoc remote execution, and keep review, retrieval, and run-time trust as separate controls rather than one assumption.

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 November 6, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org