Introducing Package Manager Guard (PMG)
Table of Contents
Let’s say you are building an Express.js application. You need a cookie parser middleware. But instead of installing the original cookie-parser package, you install express-cookie-parser which is a malicious package, although removed from the npm registry. We developers want to get the job done while in the flow state. We hate going outside our terminals and IDEs to check if a package we are installing is malicious or not. This behavior is exploited by malicious actors to compromise developers through typosquatting and other supply chain attacks. To protect the software supply chain, we need to protect developers from malicious packages at the time of installation. This is where Package Manager Guard (PMG) comes in.
What is PMG?
PMG is a tool to protect developers from malicious packages at the time of installation. It is a CLI tool that wraps popular package managers like npm, pnpm, etc. It prevents installation of malicious packages by scanning the package at the time of installation.
How do I use PMG?
The easiest way to install PMG is using homebrew. For other installation options, please refer to the PMG GitHub repository.
brew install safedep/tap/pmgIn your NPM project, you can now install any package using pmg as a security guard.
pmg npm install reactThe goal of PMG is to be as hidden and out of the way as possible while protecting developers from installing malicious packages. For a seamless experience, add PMG as an alias for your package manager.
alias npm="pmg npm"alias pnpm="pmg pnpm"That’s it! PMG will now protect you from installing malicious packages.
Demo
Bugs and Feedback
If you find any bugs or have any feedback, please file an issue on the PMG GitHub repository. You can also join SafeDep Community Discord to discuss PMG and other SafeDep products.
- pmg
- malware
- security
Author
SafeDep Team
safedep.io
Share
The Latest from SafeDep blogs
Follow for the latest updates and insights on open source security & engineering

npm SANDWORM_MODE Attack: Step-by-Step Malware Analysis
Step-by-step technical analysis of the SANDWORM_MODE npm supply chain attack. We dissect yarsg and format-defaults malicious packages, decode multi-layer obfuscation, and trace the payload delivery...

Why We Built a Hosted MCP Server to Stop Malicious Packages for AI Agents
Exposing an MCP server is trivial. Making it useful for AI agents is not. Here's what we learned dogfooding our own tool, and why we built a hosted MCP server backed by real-time open source threat...

AI Agent Cline v2.3.0 Compromised: From Prompt Injection to Unauthorized npm Publish
A compromised npm token was used to publish a tampered version of Cline CLI. A prompt injection vulnerability in Cline's AI-powered GitHub Actions workflow may have enabled the credential theft.

End-to-End test with Nextjs, Playwright and MSW
A practical Next.js 16 App Router E2E setup with Playwright and MSW that keeps server-side fetch deterministic by focusing mocking where it matters, not on server actions.

Ship Code
Not Malware
Install the SafeDep GitHub App to keep malicious packages out of your repos.
