Hide Secrets from AI Agents and NPM install using Airgap
The article explains how to protect sensitive secrets (like API keys) from being exfiltrated by AI coding agents or malicious npm packages by using an "airgap" technique—running builds and dependency installations on a separate, offline machine to ensure secrets never touch potentially compromised environments.
Background
- **AI agents** (e.g., Cursor, Copilot, Devin) are tools that can read, write, and execute code on your machine. They often have broad file-system access, including to private keys, tokens, or .env files.
- **NPM install** runs code from the internet automatically (via "preinstall"/"postinstall" scripts), creating a supply-chain risk: a compromised package could exfiltrate secrets from your environment or project.
- **Airgap** traditionally means keeping a machine physically disconnected from any network. The article proposes a lighter-weight "logical airgap": a separate "secrets host" (e.g., a WSL2 Linux instance) that has no internet access, where you store credentials and sign commits, while your main workstation runs AI agents and npm install with network access but no secrets.
- This is a response to the growing tension between convenience (AI-assisted coding, open-source packages) and security: typical solutions like permission managers or sandboxes are immature or impractical for daily development work.