airlock

airlock

MCP server that vets package installations and shell commands to block dangerous actions by AI coding agents.

Category
访问服务器

README

Airlock

A firewall between AI coding agents and dangerous actions.

Airlock blocks hallucinated/slopsquatted package installs, package execution, leaked secrets, destructive shell commands, and suspicious test changes before they ship. It works as a CLI, an MCP server, a Claude Code PreToolUse hook, a git pre-commit hook, and universal PATH shims for any agent or human using your shell.

npx airlock-cli demo
Airlock demo: AI agent wants to run this:

 BLOCK  npx fast-csv-helper init && rm -rf ~
  x Recursive force-delete targeting a root/home path (rm -rf on / ~ or $HOME).
  x [fast-csv-helper] Package "fast-csv-helper" does not exist on npm.

Stopped before anything executed.

AI coding assistants can hallucinate plausible package names. Security researchers call the attack pattern slopsquatting: attackers register names that models tend to invent, then wait for developers or agents to install them. See research from Cloud Security Alliance, Trend AI Security, and Socket.

Airlock is the seatbelt: let the agent move fast, but force the scary stuff through a deterministic check first.

Quick Start

# one-off package checks
npx airlock-cli check express
npx airlock-cli check requests -e pypi

# vet a whole command before an agent runs it
npx airlock-cli vet-command "npx fast-csv-helper init && rm -rf ~"

# run the full repo safety pass before saying "done"
npx airlock-cli audit

# see which protection layers are installed
npx airlock-cli doctor

Exit codes:

  • 0: no blocking finding for the command
  • 1: blocked package/command, leaked secret, or audit finding
  • 2: usage error

Wire It Into Your Agent

npx airlock-cli init claude-code   # MCP + native PreToolUse hook
npx airlock-cli init codex         # MCP in ~/.codex/config.toml
npx airlock-cli init gemini        # MCP in ~/.gemini/settings.json
npx airlock-cli init cursor        # MCP in .cursor/mcp.json
npx airlock-cli init shell         # universal PATH shims
npx airlock-cli init git           # pre-commit secrets + test-change guard
npx airlock-cli init all
Surface Integration What it protects
Claude Code MCP + PreToolUse hook Blocks dangerous Bash tool calls before execution
Codex MCP server Gives Codex vet_package and vet_command tools
Gemini CLI MCP server Gives Gemini vet_package and vet_command tools
Cursor MCP server Gives Cursor vet_package and vet_command tools
Any shell / any agent PATH shims Intercepts package managers at the process level
Git pre-commit hook Blocks leaked secrets and suspicious staged test changes

Claude Code hooks can return permissionDecision: "deny" for PreToolUse events, so Airlock can block a Bash command without relying on the model to remember a rule. Claude Code, Codex, Gemini CLI, and Cursor all support MCP server configuration; Airlock writes those config files for you.

Universal Shell Guard

For the wrapper-agnostic layer:

npx airlock-cli guard install
export PATH="$HOME/.airlock/shims:$PATH"

This installs shims for:

npm, npx, pnpm, yarn, bun, bunx, pip, pip3, pipx, uv, uvx, poetry, cargo, gem, bundle, bundler, go

Now these are vetted whether they are run by you, Claude Code, Codex, Gemini, Cursor, OpenCode, Roo, Cline, a random shell script, or anything else:

npm install express
npx create-next-app@latest app
pnpm dlx shadcn@latest init
uvx ruff check
pipx run black .
cargo add serde
gem install rails
go install github.com/gin-gonic/gin@latest

Remove shims:

npx airlock-cli guard uninstall

What Airlock Checks

Dependency and package-execution guard (npm, PyPI, crates.io, RubyGems, Go modules):

  • Package existence: nonexistent packages/modules -> block
  • Typosquat: expresss -> express
  • Mashup/slopsquat: lodash-utils, requests-helper
  • New + low adoption: recently published packages with weak adoption -> warn/block
  • Provenance: missing source repository or deprecated packages -> warn
  • Package executors: npx, npm exec, pnpm dlx, yarn dlx, bunx, uvx, pipx run
  • Scaffold aliases: npm create vite maps to the actual create-vite package before vetting
  • Manifest scan: package.json, requirements.txt, pyproject.toml, Cargo.toml, Gemfile, go.mod

Destructive-command guard:

  • rm -rf /, rm -rf ~, rm --no-preserve-root -> block
  • fork bombs, dd/mkfs to devices, redirects to raw block devices -> block
  • git push --force, git reset --hard, git clean -f -> warn
  • DROP TABLE, TRUNCATE TABLE, curl ... | sh -> warn
  • package execution from URL/Git specs -> warn

Repo-audit guards:

  • airlock secrets blocks high-confidence GitHub/OpenAI/Anthropic/AWS/Slack tokens and private keys
  • airlock diff --staged warns on suspicious test changes: removed assertions, skipped tests, focused-only tests, or deleted test files
  • airlock audit runs dependency, secret, and test-change checks together

In Claude Code:

  • BLOCK -> deny
  • WARN -> ask
  • ALLOW -> silent

Project Policy

Private packages and team decisions belong in policy, not in CLI flags:

npx airlock-cli policy init

Creates .airlock.json:

{
  "allow": {
    "npm": ["@your-org/*"],
    "pypi": ["your-private-package"],
    "cargo": ["your-private-crate"],
    "rubygems": ["your-private-gem"],
    "go": ["github.com/your-org/*"]
  },
  "block": {
    "npm": ["known-bad-package"],
    "pypi": ["known-bad-package"],
    "cargo": ["known-bad-crate"],
    "rubygems": ["known-bad-gem"],
    "go": ["github.com/bad/*"]
  }
}

Policy files are discovered from the current directory upward, so a repo can carry its own allow/block rules.

GitHub Action

Use Airlock in CI before merging agent-generated changes:

name: Airlock

on: [pull_request]

jobs:
  airlock:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: cjaston/airlock@main
        with:
          path: "."

MCP Tools

Airlock exposes these MCP tools:

  • vet_package({ name, ecosystem, cwd? })
  • vet_command({ command, cwd? })
  • scan_project({ cwd? })
  • scan_secrets({ cwd? })
  • scan_diff({ cwd?, staged? })
  • audit_project({ cwd?, staged? })

Agents should call vet_command before shell commands that install packages, execute packages, delete files, rewrite git history, touch disks, or touch databases. Agents should call audit_project before finishing or committing code. If the result is BLOCK, do not run the command.

Privacy

  • No backend
  • No telemetry
  • Package names are looked up directly against public registry APIs
  • Registry facts are cached locally in ~/.airlock/cache
  • Disable cache for a run with AIRLOCK_NO_CACHE=1
npx airlock-cli cache status
npx airlock-cli cache clear

Build From Source

git clone https://github.com/cjaston/airlock.git
cd airlock
npm install
npm test
node dist/index.js demo

Requires Node 20+.

Acknowledgements

Built by Chris Jaston with AI-assisted development from OpenAI Codex. Airlock is an independent open-source project and is not an official OpenAI product or endorsement.

Roadmap

  • [x] npm + PyPI + crates.io + RubyGems + Go module checks
  • [x] typosquat + mashup/slopsquat heuristics
  • [x] npx/dlx/uvx/pipx package execution checks
  • [x] destructive-command guard
  • [x] MCP server (vet_package, vet_command)
  • [x] Claude Code PreToolUse hook
  • [x] universal PATH shims
  • [x] project policy file (.airlock.json)
  • [x] repo manifest scan
  • [x] secret-leak guard
  • [x] test-subversion detector
  • [x] git pre-commit hook
  • [ ] more ecosystems: maven, nuget, composer
  • [ ] signed policy bundles for teams

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选