---
title: "Blocking malicious install scripts · airgap"
description: "Defend against malicious npm postinstall, setup.py and build.rs hooks: airgap audits manifests locally and refuses lifecycle scripts by default."
url: https://www.useairgap.dev/guides/supply-chain-hardening
---

[All guides](https://www.useairgap.dev/guides)

# Blocking malicious install scripts

Defend against malicious npm postinstall, setup.py and build.rs hooks: airgap audits manifests locally and refuses lifecycle scripts by default.

## Blocking malicious install scripts

**The danger of automated dependency installation:** Modern package managers (`npm`, `pip`, `Cargo`) allow third-party packages to execute arbitrary code during installation via `postinstall`, `preinstall`, `setup.py`, and `build.rs` hooks. Attackers routinely publish typosquatted or compromised packages that run obfuscated infostealers the moment an agent runs `npm install` to test a PR.

> `use airgap to audit this package.json before we install`

### Two layers of supply-chain defense

airgap defends against hostile dependencies both _before_ install and _during_ install:

1. **Static local manifest audit (`airgap_audit_supply`):** Inspects `package.json`, `requirements.txt`, and `Cargo.toml` locally with zero cloud calls. Flags lifecycle scripts, build scripts, git URLs, direct tarball URLs, and alternate registries.
2. **Safe defaults on PR verification (`airgap_verify_pr`):** Runs with `fail_on_supply_risk: true` and `allow_install_scripts: false` by default. Any PR introducing an unexpected install hook is blocked before the sandbox ever installs packages.
3. **Disposable microVM blast radius:** Even when you intentionally test a package inside `airgap_sandbox_run`, it executes inside an ephemeral Linux microVM with no access to your host credentials, npmrc tokens, or SSH agent.

### Risk signals across ecosystems

| Ecosystem | Lifecycle / build hook | Recommended safe command in sandbox |
| --- | --- | --- |
| npm / pnpm / yarn | `preinstall, install, postinstall, prepare` | `npm ci --ignore-scripts` |
| Python (pip) | `setup.py / source distributions (sdist)` | `pip install --only-binary=:all: -r requirements.txt` |
| Rust (Cargo) | `build.rs, proc-macros, git/path deps` | Audit Cargo.toml first, then cargo test inside airgap microVM |

### What static manifest auditing does not cover

`airgap_audit_supply` evaluates the manifest text you submit; it does not resolve transitive dependencies from a registry, inspect downloaded package source code, or query CVE advisory databases. Treat it as a fast, zero-cost front gate paired with disposable microVM execution. See [Audit a dependency manifest](https://www.useairgap.dev/guides/manifest) for direct tool arguments.

## Keep reading

[All 12 guides](https://www.useairgap.dev/guides)

### [Zero credential leakage](https://www.useairgap.dev/guides/secret-scrubbing)

Known key formats plus entropy checks, run on your machine.

### [The zero-trust MCP playbook](https://www.useairgap.dev/guides/team-playbook)

Routing rules plus client permissions for a whole team.
