* feat: add experimental Go module support via pmg go Adds Go modules as a proxy-guarded ecosystem, opt-in only: the command runs solely when invoked explicitly as `pmg go ...` and is deliberately excluded from setup aliases and PATH shims so existing users are unaffected. - packagemanager: goPackageManager with fail-safe command classification (vet/fix excluded from non-download since they can fetch on a cold cache) and pinned-version extraction where only canonical semver counts as explicit. - GOPROXY normalization (fail-closed): effective GOPROXY read via `go env` (honors go env -w), rebuilt comma-joined with `direct` dropped so a 403 block is terminal and nothing silently falls back to unanalyzed VCS fetches. GOPRIVATE/GONOPROXY surface a warning; GOINSECURE is cleared. Contributed to the proxy flow through a new ProxyRoutingProvider hook (extra child env + dynamic MITM hosts). - Go interceptor with dynamic host matching from the user's effective GOPROXY via InterceptorContext.GoProxyHosts. Malware analysis runs on .zip only (the sole endpoint that delivers code); .info/.mod/@latest/ list pass through; /sumdb/ traffic and sum.golang.org are never touched so checksum-db verification stays intact; golang.org/toolchain is allowed on Go's own checksum verification. - Dependency cooldown: publish time captured from .info responses (body unmodified), in-window .zip blocked with 403; fails open for cooldown only when the publish time was never observed. - Cert gate: on macOS/Windows `pmg go` fails fast with actionable guidance unless the persisted PMG CA is OS-trusted (Go ignores SSL_CERT_FILE there); Linux works via the injected bundle. - proxye2e: GOPROXY-protocol mock registry, Go driver and 10 hermetic cases (allow/block/confirm, case-escaped paths, cooldown block and fail-open, toolchain, sumdb passthrough). Verified end-to-end on Linux: `pmg go get github.com/google/uuid@v1.6.0` MITMs proxy.golang.org, analyzes the decoded module at the .zip fetch, and go.sum verification succeeds through the tunneled checksum db. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014xuhBeTVpfU4SdqVaarvuK * fix(go): address review findings on experimental Go support - Drop fmt/clean from NonDownloadCommands: both load packages via go list and can download modules on a cold cache, which would bypass the proxy under install_only. - Support GOPROXY entries with a base path (e.g. corp Athens/JFrog at https://corp/goproxy): the interceptor now receives host -> base URL and strips the path prefix before parsing module URLs, so verdicts and cooldown key on the real module path. - Default unschemed GOPROXY entries to https, matching go's own behavior, so corp mirrors configured as bare hosts are intercepted instead of silently unanalyzed. - Memoize the final verdict per module zip: go re-requests a failed zip during go get's load phase, which double-recorded stats (the report showed the same blocked module twice) and would have re-prompted on Confirm verdicts. - Fetch .info out-of-band on a cooldown cache miss: go serves .info from its local module cache on any machine that used go before PMG, which silently disabled cooldown. Failure of the side-fetch still fails open for cooldown only. - Move the noop package resolver into packagemanager. Verified live: cold-cache cooldown block now records once; warm-cache rerun is blocked via the side-fetch instead of failing open. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014xuhBeTVpfU4SdqVaarvuK * docs: collapse Go proxy-mode details by default Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014xuhBeTVpfU4SdqVaarvuK --------- Co-authored-by: Claude <noreply@anthropic.com>
Package Manager Guard (PMG)
Block malicious npm and pip packages before they install.
Defense in depth for the package managers you already use.
Why PMG?
Developers and AI coding agents install packages every day. Each npm install or pip install executes thousands of lines of code that nobody reviews.
Recent compromises in popular ecosystems:
- Mini Shai-Hulud - 300+ popular packages compromised
- litellm 1.82.8 - a popular AI proxy library compromised to exfiltrate credentials
- telnyx 4.87.2 - a legitimate telecom SDK hijacked on PyPI
- pino-sdk-v2 - a typosquat package disguised as the popular pino logger
PMG is free, open source (Apache 2.0), and requires no account or API key. It intercepts every package install and checks it against SafeDep's free community API for known malware before code executes. Install it once, and it covers every npm install, pip install, and poetry add after that.
How PMG Works
PMG takes a defense in depth approach. Zero config, works across Zsh, Bash, and Fish, and each install passes through the enabled protection layers before code runs, plus an audit trail after.
Layer details
- Transparent Interception - PMG wraps
npm,pip, and other package managers. Developers and AI agents use the same commands. No workflow changes. - Layer 1: Threat Intelligence - PMG checks every package against SafeDep's real-time threat intelligence before install. Known-malicious packages are blocked. No key, no login required.
- Layer 2: Policy (Dependency Cooldown) - PMG blocks package versions published inside a configurable cooldown window, so recently compromised versions are skipped during the window.
- Layer 3: Opt-in Sandbox - When sandboxing is enabled and configured, PMG runs installs inside OS-native sandboxes (macOS Seatbelt, Linux Landlock by default, or Bubblewrap fallback) so install scripts have restricted system access even if a threat slips past the first two layers.
- Audit Logging - PMG logs every install (what, when, from where) for a verifiable audit trail.
How PMG Compares
PMG is the only free, open-source, install-time package firewall that covers developers and AI agents alike and ships with sandboxing and cooldown out of the box.
| Capability | PMG | Socket | safe-chain | Snyk | Dependabot |
|---|---|---|---|---|---|
| OSS / built in public | ✓ | ✗ | ✓ | ✗ | ✗ |
| No account or API key | ✓ | ✓ | ✓ | ✗ | ✗ |
| Install-time malicious package blocking | ✓ | ✓ | ✓ | ✗ | ✗ |
| Dependency cooldown policy | ✓ | ✗ | ✓ | ✗ | ✗ |
| Runtime sandboxing | ✓ | ✗ | ✗ | ✗ | ✗ |
| Protects AI coding agents transparently | ✓ | ✗ | ✗ | ✗ | ✗ |
| Local audit logs | ✓ | ✗ | ✗ | ✗ | ✗ |
| Known-CVE remediation PRs | ✗ | ✗ | ✗ | ✓ | ✓ |
Quick Start
1. Install
curl -fsSL https://raw.githubusercontent.com/safedep/pmg/main/install.sh | sh
See Installation for Homebrew, npm, and other install methods.
2. Setup
Wire PMG into your shell so it intercepts package managers.
pmg setup install
# Restart your terminal to apply changes
Tip: Re-run
pmg setup installafter upgrading PMG to pick up new configuration options.
Validate your installation and verify protection is working:
pmg setup doctor
Optional: PMG inspects HTTPS traffic with an on-the-fly CA that it injects into package managers per run. To persist a single CA across runs and trust it in your OS trust store (needed for tools that ignore CA environment variables, such as Go on macOS and Windows), install it once:
pmg setup cert install # user scope, no sudo pmg setup cert status # check trust state and expirySee Certificate Authority for scopes, rotation, and removal.
3. Use
See PMG blocking threats.
npm install --no-cache --prefer-online safedep-test-pkg@0.1.3
Note:
safedep-test-pkgis a benign test package flagged as malicious in SafeDep's database for testing and verification purposes.
Continue using your package managers as usual, or let your AI coding agent run them. PMG sits in the path, blocking malicious packages.
npm install express
# or
pip install requests
Supported Package Managers
PMG supports the tools you already use:
| Ecosystem | Tools | Command Example |
|---|---|---|
| Node.js | npm |
npm install <pkg> |
pnpm |
pnpm add <pkg> |
|
yarn |
yarn add <pkg> |
|
bun |
bun add <pkg> |
|
npx |
npx <pkg> |
|
pnpx |
pnpx <pkg> |
|
| Python | pip |
pip install <pkg> |
pipx |
pipx run <pkg> |
|
poetry |
poetry add <pkg> |
|
uv |
uv add <pkg> |
|
uvx |
uvx <pkg> |
Installation
Install Script (MacOS/Linux)
Downloads the latest release from GitHub, verifies its SHA-256 checksum, and installs to $HOME/.local/bin (if on PATH) or /usr/local/bin.
curl -fsSL https://raw.githubusercontent.com/safedep/pmg/main/install.sh | sh
Homebrew (MacOS/Linux)
brew tap safedep/tap
brew install safedep/tap/pmg
NPM (Cross-Platform)
npm install -g @safedep/pmg
Note: NPM-based installs can be fragile when Node.js is managed by version managers like
miseorasdf. The globalnpmbin path changes with the active Node version, so switching versions can leavepmgunavailable onPATH(or pointing to an old install). For these setups, prefer the install script or Homebrew.
Go (Build from Source)
# Ensure $(go env GOPATH)/bin is in your $PATH
go install github.com/safedep/pmg@latest
Binary Download
Download the latest binary for your platform from the Releases Page.
GitHub Actions
Protect CI workflows with one step. PMG analyzes every npm install,
pip install, etc. in the job.
- uses: safedep/pmg@v1
with:
server-mode: true
# intercepted via HTTP_PROXY automatically
- run: npm ci
- name: Enforce PMG policy
if: always()
run: pmg proxy stop --fail-on-violation # stops the daemon, fails the job on a block
By default you get malware blocking and dependency cooldown. Sandbox isolation
is opt-in via the sandbox input. Tune behavior via inputs (paranoid,
sandbox, cooldown-days, ...) or point
config-file at a YAML in the repo. See
docs/github-action.md for the full reference.
Uninstallation
Remove shell integration:
pmg setup remove
To also remove the PMG configuration file:
pmg setup remove --config-file
Then uninstall PMG itself:
# Homebrew
brew uninstall safedep/tap/pmg
# NPM
npm uninstall -g @safedep/pmg
Trust and Security
PMG builds are reproducible and signed.
- Attestations: GitHub and npm attestations guarantee artifact integrity.
- Verification: You can cryptographically prove the binary matches the source code.
- See Trusting PMG for verification steps.
User Guide
- Configuration
- Trusted Packages Configuration
- Dependency Cooldown
- Caching
- Proxy Mode Architecture
- Persistent Proxy Server
- Certificate Authority
- Sandboxing
Support
If PMG saved you from a bad package, star this repo. It helps others find it.
Star History
Contributing
Contributions welcome. See CONTRIBUTING.md for build and test instructions.
Thank you to all contributors ❤️
Telemetry
PMG collects anonymous usage data. To disable, either:
- Set
disable_telemetry: truein your PMG config file, or - Export
PMG_DISABLE_TELEMETRY=true.
