attach-guard
AI agents install packages. Attach checks them first.
The Problem
Claude Code installs packages on your behalf — often without you reviewing each one. Existing security tools scan after the fact or rely on advisory prompts that Claude can skip. There is no open-source guardrail that sits directly in front of package install commands and blocks risky packages before they execute.
What attach-guard Does
attach-guard is a Claude Code plugin that intercepts package installation commands and evaluates them against policy before execution. It is not an advisory scanner. It is a hard enforcement boundary.
- Installs as a Claude Code plugin — no manual hook configuration needed
- Intercepts
npm install, pnpm add, direct pip / pip3 install, python -m pip install / python3 -m pip install wrappers, uv pip install, go get / go install, and cargo add / cargo install commands via PreToolUse hooks
- Evaluates packages with the configured provider before install commands run
- Supports explicit provider configuration, including local Attach Open Score, Attach Open Score-compatible verdict endpoints, and legacy local BYO-token providers
- Denies known malware and high-confidence dangerous packages automatically
- Asks for confirmation on gray-band packages and provider-unavailable cases in local mode
- Rewrites unpinned installs to safe pinned versions when possible
- Logs every decision to a local JSONL audit trail
Attach Open Score is the first-party scoring direction. By default, open-score shells out to a local attach-open-score package command and can also be pointed at an explicit Attach Open Score-compatible HTTP verdict endpoint. No hosted/default Attach scoring endpoint is baked into attach-guard. See Attach Open Score provider semantics and Local Attach Open Score dogfood guide for public-safe verification.
Smart Version Replacement: Block Without Breaking Flow
Most security tools just say "no." attach-guard says "no, but here's a safe alternative."
When a risky version is blocked, attach-guard finds the newest version that passes policy and offers it as a replacement. Claude sees the safe alternative and can proceed immediately — your flow doesn't stop, it gets redirected to a safe path.
npm — axios v1.14.1 and v0.30.4 were publicly reported compromised versions published via a hijacked maintainer account:
> npm install axios
attach-guard evaluates:
[email protected] --> DENY (known compromised version)
[email protected] --> ALLOW (passes configured policy checks)
Result: ASK + rewritten command
"npm install [email protected]"
pip — litellm v1.82.7 and v1.82.8 were malicious versions published to PyPI:
> pip install litellm
attach-guard evaluates:
litellm==1.82.8 --> DENY (compromised version)
litellm==1.82.6 --> ALLOW (passes all policy checks)
Result: ASK + rewritten command
"pip install litellm==1.82.6"
These examples illustrate the current enforcement flow: attach-guard blocks known compromised or policy-failing versions and offers a safe pinned alternative when one is available.
| Scenario | Example | Decision | What happens |
|---|
| Package is safe | npm install [email protected] | Allow | Install proceeds normally |
| Pinned to compromised version | pip install litellm==1.82.8 | Deny | Blocked — compromised version |
| Unpinned, latest is risky | npm install axios | Ask + rewrite | Safe alternative offered: [email protected] |
| All versions fail | malware-only package | Deny | Blocked with clear explanation |
This works across all supported ecosystems — the rewrite uses the native pinning syntax for each:
| Ecosystem | Unpinned command | Rewritten command |
|---|
| npm / pnpm | npm install axios | npm install [email protected] |
| pip | pip install litellm | pip install litellm==1.82.6 |
| Go | go get golang.org/x/net | go get golang.org/x/[email protected] |
| Cargo | cargo add serde | cargo add serde@=1.0.200 |
Supported pip wrappers such as python -m pip install, python -I -m pip install, and uv pip install are evaluated before execution. If a wrapped pip command needs a safe-version rewrite, attach-guard asks for manual review instead of rewriting the wrapper command.
Your flow only fully stops when there is genuinely no safe version to offer.
Why a Hook, Not a Skill or MCP
attach-guard uses Claude Code hooks — not skills or MCP servers. The distinction matters: