2026-01-21 20:29:15 +05:30
<div align="center">
<h1>Package Manager Guard (PMG)</h1>
</div>
2026-05-19 15:18:03 +05:30
<p align="center">
<strong>Block malicious npm and pip packages before they install.</strong><br>
Defense in depth for the package managers you already use.
</p>
<div align="center">
<img src="./docs/demo/pmg-intro.gif" width="800" alt="pmg in action">
</div>
<br>
2026-01-21 20:29:15 +05:30
<div align="center">
2026-01-27 19:39:36 +05:30
[](https://docs.safedep.io/pmg/quickstart)
[](https://safedep.io)
[](https://discord.gg/kAGEj25dCn)
2026-05-26 22:15:14 +05:30
[](https://tldrsec.com/p/tldr-sec-316)
2025-05-15 21:34:41 +05:30
[](https://goreportcard.com/report/github.com/safedep/pmg)


[](https://api.securityscorecards.dev/projects/github.com/safedep/pmg)
[](https://github.com/safedep/pmg/actions/workflows/codeql.yml)
2026-01-21 20:29:15 +05:30
</div>
2026-02-16 13:35:58 +05:30
## Why PMG?
2025-04-23 02:21:44 +05:30
2026-04-07 00:56:21 +05:30
Developers and AI coding agents install packages every day. Each `npm install` or `pip install` executes thousands of lines of code that nobody reviews.
2026-01-15 20:12:12 +05:30
2026-05-19 15:18:03 +05:30
Recent compromises in popular ecosystems:
2026-02-16 13:35:58 +05:30
2026-05-19 15:18:03 +05:30
- [**Mini Shai-Hulud** ](https://safedep.io/mini-shai-hulud-strikes-again-314-npm-packages-compromised/ ) - 300+ popular packages compromised
2026-04-07 00:56:21 +05:30
- [**litellm 1.82.8** ](https://safedep.io/malicious-litellm-1-82-8-analysis/ ) - a popular AI proxy library compromised to exfiltrate credentials
- [**telnyx 4.87.2** ](https://safedep.io/malicious-telnyx-pypi-compromise/ ) - a legitimate telecom SDK hijacked on PyPI
- [**pino-sdk-v2** ](https://safedep.io/malicious-npm-package-pino-sdk-v2-env-exfiltration/ ) - a typosquat package disguised as the popular pino logger
2025-04-23 02:21:44 +05:30
2026-05-26 22:15:14 +05:30
**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 ](https://safedep.io ) for known malware **before** code executes. Install it once, and it covers every `npm install` , `pip install` , and `poetry add` after that.
2026-03-11 11:04:05 +05:30
2026-04-07 00:56:21 +05:30
## How PMG Works
2026-03-11 11:04:05 +05:30
2026-05-26 22:15:14 +05:30
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.
<div align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="./docs/assets/how-pmg-works-dark.svg">
<img alt="PMG defense in depth: install command intercepted by PMG, passed through Layer 1 Threat Intel, Layer 2 Cooldown, Layer 3 Sandbox, then run with an audit log entry" src="./docs/assets/how-pmg-works-light.svg" width="820">
</picture>
</div>
<details>
<summary><strong>Layer details</strong></summary>
2026-05-19 15:18:03 +05:30
- **Transparent Interception** - PMG wraps `npm` , `pip` , and other package managers. Developers and AI agents use the same commands. No workflow changes.
2026-05-26 22:15:14 +05:30
- **Layer 1: Threat Intelligence** - PMG checks every package against [SafeDep's real-time threat intelligence ](https://safedep.io ) 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.
2026-05-19 15:18:03 +05:30
- **Audit Logging** - PMG logs every install (what, when, from where) for a verifiable audit trail.
2026-03-11 11:04:05 +05:30
2026-05-26 22:15:14 +05:30
</details>
## 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 | Snyk | Dependabot |
| --------------------------------------- | --- | ------- | ---- | ---------- |
| OSS / built in public | ✓ | ✗ | ✗ | ✗ |
2026-05-27 12:12:11 +05:30
| No account or API key | ✓ | ✓ | ✗ | ✗ |
2026-05-26 22:15:14 +05:30
| Install-time malicious package blocking | ✓ | ✓ | ✗ | ✗ |
| Dependency cooldown policy | ✓ | ✗ | ✗ | ✗ |
| Runtime sandboxing | ✓ | ✗ | ✗ | ✗ |
| Protects AI coding agents transparently | ✓ | ✗ | ✗ | ✗ |
| Local audit logs | ✓ | ✗ | ✗ | ✗ |
| Known-CVE remediation PRs | ✗ | ✗ | ✓ | ✓ |
2026-01-21 20:29:15 +05:30
## Quick Start
2025-05-15 18:03:46 +05:30
2026-02-16 13:35:58 +05:30
### 1. Install
2026-05-04 21:46:58 +05:30
```bash
curl -fsSL https://raw.githubusercontent.com/safedep/pmg/main/install.sh | sh
```
2026-05-19 15:18:03 +05:30
> See [Installation](#installation) for Homebrew, npm, and other install methods.
2026-01-08 00:24:18 +05:30
2026-02-16 13:35:58 +05:30
### 2. Setup
2025-05-15 16:50:59 +05:30
2026-05-19 15:18:03 +05:30
Wire PMG into your shell so it intercepts package managers.
2026-02-16 13:35:58 +05:30
```bash
2025-06-24 18:17:06 +05:30
pmg setup install
2026-02-16 13:35:58 +05:30
# Restart your terminal to apply changes
2025-05-15 16:50:59 +05:30
```
2026-03-31 19:54:25 +05:30
> **Tip:** Re-run `pmg setup install` after upgrading PMG to pick up new configuration options.
2026-05-26 12:21:39 +05:30
Validate your installation and verify protection is working:
```bash
pmg setup doctor
```
2026-02-16 13:35:58 +05:30
### 3. Use
2026-01-09 19:26:48 +05:30
2026-05-26 22:15:14 +05:30
See PMG blocking threats.
```bash
npm install --no-cache --prefer-online safedep-test-pkg@0.1.3
```
> **Note:** `safedep-test-pkg` is 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.
2025-05-15 16:50:59 +05:30
2026-02-16 13:35:58 +05:30
```bash
npm install express
# or
pip install requests
2025-05-15 18:03:46 +05:30
```
2025-05-15 16:50:59 +05:30
## Supported Package Managers
2025-04-23 02:21:44 +05:30
2026-02-16 13:35:58 +05:30
PMG supports the tools you already use:
2025-05-15 16:50:59 +05:30
2026-05-19 15:18:03 +05:30
| 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>` |
| | `poetry` | `poetry add <pkg>` |
| | `uv` | `uv add <pkg>` |
2025-04-23 02:21:44 +05:30
## Installation
2025-05-15 16:50:59 +05:30
2026-05-04 21:46:58 +05:30
<details>
<summary><strong>Install Script (MacOS/Linux)</strong></summary>
Downloads the latest release from GitHub, verifies its SHA-256 checksum, and installs to `$HOME/.local/bin` (if on `PATH` ) or `/usr/local/bin` .
```bash
curl -fsSL https://raw.githubusercontent.com/safedep/pmg/main/install.sh | sh
```
</details>
2026-02-16 13:35:58 +05:30
<details>
<summary><strong>Homebrew (MacOS/Linux)</strong></summary>
2025-05-15 22:24:02 +05:30
```bash
brew tap safedep/tap
brew install safedep/tap/pmg
```
2026-02-16 13:35:58 +05:30
</details>
2025-05-15 16:50:59 +05:30
2026-02-16 13:35:58 +05:30
<details>
<summary><strong>NPM (Cross-Platform)</strong></summary>
2025-04-23 02:21:44 +05:30
```bash
2026-02-16 13:35:58 +05:30
npm install -g @safedep/pmg
```
2026-05-04 21:46:58 +05:30
> **Note:** NPM-based installs can be fragile when Node.js is managed by version managers like [`mise`](https://mise.jdx.dev/) or [`asdf`](https://asdf-vm.com/). The global `npm` bin path changes with the active Node version, so switching versions can leave `pmg` unavailable on `PATH` (or pointing to an old install). For these setups, prefer the install script or Homebrew.
2026-02-16 13:35:58 +05:30
</details>
<details>
<summary><strong>Go (Build from Source)</strong></summary>
```bash
# Ensure $(go env GOPATH)/bin is in your $PATH
2025-04-28 20:02:20 +05:30
go install github.com/safedep/pmg@latest
2025-04-23 02:21:44 +05:30
```
2026-02-10 22:22:40 +05:30
</details>
2026-01-08 00:24:18 +05:30
<details>
2026-02-16 13:35:58 +05:30
<summary><strong>Binary Download</strong></summary>
2025-05-15 16:50:59 +05:30
2026-02-16 13:35:58 +05:30
Download the latest binary for your platform from the [Releases Page ](https://github.com/safedep/pmg/releases ).
2026-01-08 00:24:18 +05:30
</details>
2026-05-18 00:44:06 +05:30
## GitHub Actions
2026-05-19 15:18:03 +05:30
Protect CI workflows with one step. PMG analyzes every `npm install` ,
`pip install` , etc. in the job.
2026-05-18 00:44:06 +05:30
```yaml
2026-05-19 15:18:03 +05:30
# Consider pinning third-party Actions to a full commit SHA
- uses : actions/setup-node@v6
2026-05-18 00:44:06 +05:30
with :
node-version : 24
- uses : safedep/pmg@v1
- run : npm ci
```
2026-05-20 13:56:50 +05:30
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
2026-05-19 15:18:03 +05:30
`config-file` at a YAML in the repo. See
[docs/github-action.md ](docs/github-action.md ) for the full reference.
2026-05-18 00:44:06 +05:30
2026-04-07 00:56:21 +05:30
## Uninstallation
Remove shell integration:
```bash
pmg setup remove
```
To also remove the PMG configuration file:
```bash
pmg setup remove --config-file
```
Then uninstall PMG itself:
```bash
# Homebrew
brew uninstall safedep/tap/pmg
# NPM
npm uninstall -g @safedep/pmg
```
2026-02-16 13:35:58 +05:30
## Trust and Security
2025-05-16 19:38:06 +05:30
2026-05-19 15:18:03 +05:30
PMG builds are reproducible and signed.
2026-02-16 13:35:58 +05:30
2026-05-19 15:18:03 +05:30
- **Attestations**: GitHub and npm attestations guarantee artifact integrity.
- **Verification**: You can cryptographically prove the binary matches the source code.
- See [Trusting PMG ](docs/trust.md ) for verification steps.
2026-02-16 13:35:58 +05:30
2026-03-11 11:04:05 +05:30
## User Guide
2026-01-08 00:24:18 +05:30
2026-05-26 22:15:14 +05:30
- [Configuration ](docs/config.md )
2026-05-19 15:18:03 +05:30
- [Trusted Packages Configuration ](docs/trusted-packages.md )
- [Dependency Cooldown ](docs/dependency-cooldown.md )
- [Proxy Mode Architecture ](docs/proxy-mode.md )
2026-05-26 22:15:14 +05:30
- [Sandboxing ](docs/sandbox.md )
2026-01-09 19:26:48 +05:30
2026-03-11 11:04:05 +05:30
## Support
2026-05-19 15:18:03 +05:30
If PMG saved you from a bad package, [star this repo ](https://github.com/safedep/pmg ). It helps others find it.
2026-03-11 11:04:05 +05:30
2026-05-26 22:15:14 +05:30
## Star History
<a href="https://star-history.com/#safedep/pmg &Date">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=safedep/pmg&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=safedep/pmg&type=Date" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=safedep/pmg&type=Date" />
</picture>
</a>
2026-01-08 00:24:18 +05:30
## Contributing
2025-05-15 16:50:59 +05:30
2026-05-19 15:18:03 +05:30
Contributions welcome. See [CONTRIBUTING.md ](CONTRIBUTING.md ) for build and test instructions.
2025-06-30 09:47:14 +05:30
2026-05-26 22:15:14 +05:30
Thank you to all contributors ❤️
<a href="https://github.com/safedep/pmg/graphs/contributors">
<img src="https://contrib.rocks/image?repo=safedep/pmg" alt="Contributors to PMG" />
</a>
2025-06-30 09:47:14 +05:30
## Telemetry
2026-05-19 15:18:03 +05:30
PMG collects anonymous usage data. To disable, either:
2026-04-22 22:04:56 +05:30
- Set `disable_telemetry: true` in your PMG config file, or
- Export `PMG_DISABLE_TELEMETRY=true` .