Show HN: Safe-NPM – only install packages that are +90 days old
Recorded: Nov. 27, 2025, 1:02 a.m.
| Original | Summarized |
GitHub - kevinslin/safe-npm: Safely install NPM packages Skip to content Navigation Menu Toggle navigation
Sign in
Appearance settings Platform GitHub Copilot
Write better code with AI GitHub Spark Build and deploy intelligent apps GitHub Models Manage and compare prompts GitHub Advanced Security
Find and fix vulnerabilities Actions
Automate any workflow Codespaces
Instant dev environments Issues
Plan and track work Code Review
Manage code changes Discussions
Collaborate outside of code Code Search
Find more, search less Explore Why GitHub
Documentation
GitHub Skills
Blog
Integrations GitHub Marketplace
MCP Registry
View all features
Solutions By company size Enterprises
Small and medium teams
Startups
Nonprofits
By use case App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
By industry Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources Topics AI
DevOps
Security
Software Development
View all
Explore Learning Pathways
Events & Webinars
Ebooks & Whitepapers
Customer Stories
Partners
Executive Insights
Open Source GitHub Sponsors
Fund open source developers The ReadME Project
GitHub community articles Repositories Topics
Trending
Collections
Enterprise Enterprise platform
AI-powered developer platform Available add-ons GitHub Advanced Security
Enterprise-grade security features Copilot for business
Enterprise-grade AI features Premium Support
Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests...
Search Clear
Search syntax tips Provide feedback Include my email address so I can be contacted Cancel Submit feedback Saved searches
Name Query To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up
Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. Dismiss alert kevinslin safe-npm Public
Notifications
Fork
Star Safely install NPM packages 20 0 Branches Tags Activity
Star
Notifications Code Issues Pull requests Actions Projects Security Uh oh! There was an error while loading. Please reload this page. Insights
Additional navigation options
Code Issues Pull requests Actions Projects Security Insights
kevinslin/safe-npm
mainBranchesTagsGo to fileCodeOpen more actions menuFolders and filesNameNameLast commit messageLast commit dateLatest commit History4 Commitssrcsrc testtest .cursorindexingignore.cursorindexingignore .gitignore.gitignore README.mdREADME.md TODO.mdTODO.md package-lock.jsonpackage-lock.json package.jsonpackage.json tsconfig.jsontsconfig.json vitest.config.tsvitest.config.ts View all filesRepository files navigationREADMEsafe-npm Stealing maintainer credentials These attacks often happen suddenly—a package that was safe yesterday might be compromised today. safe-npm protects you by only installing package versions that have been publicly available for a minimum amount of time (90 days by default). This gives the security community time to discover and report malicious releases before they reach your project. Reads your dependencies from package.json or command-line arguments For example, if you specify react@^18 and a malicious react@18.5.0 was published yesterday, safe-npm will install the latest version that's at least 90 days old instead. # Now you can use it anywhere # Link the binary globally # Or specify your own minimum age # These will be filtered to only use versions at least 90 days old Increase for maximum security (e.g., 180 days for critical production systems) --ignore <pkg1,pkg2> Fast-moving packages you trust (like TypeScript or build tools) --strict CI/CD pipelines where you want builds to fail rather than skip problematic packages --dev / --prod-only safe-npm install --dev - Only install devDependencies When to use: Installing development tools with stricter requirements --strategy <direct|overrides> Simple and straightforward overrides - Writes resolved versions to package.json overrides field, then runs npm install Enforces versions across your entire dependency tree (including transitive dependencies) --registry <url> Private npm registries --dry-run Testing your configuration Common workflows # Install dependencies safely # This creates package-lock.json with versions at least 90 days old # If you're happy, install them # Or allow newer packages for dev dependencies only A popular package popular-lib is maintained by a trusted developer Limitations Won't protect against packages that were malicious from the start Philosophy Regular security audits (npm audit) Requirements Node.js 18 or higher License About Safely install NPM packages Readme Uh oh! There was an error while loading. Please reload this page. Activity 20 0 0 Report repository Releases Packages No packages published Languages TypeScript JavaScript Footer © 2025 GitHub, Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. |
safe-npm is a security-focused npm installer designed to mitigate the rising threat of supply chain attacks on Node.js projects. The core functionality centers around selectively installing npm packages based on their publication age, providing a defense mechanism against quickly-deployed, potentially malicious updates. This summary will detail its operation, configuration options, and intended usage. The project’s rationale stems from the increasing risk of compromised npm packages. Attackers can exploit compromised maintainer credentials or inject malware into widely-used packages. The attacker can, for example, take over an abandoned package or publish malicious updates. The key benefit of safe-npm is that it prevents projects from immediately installing these newly-compromised versions by filtering packages based on how long they have been publicly available. The default age threshold is 90 days, intended to grant the security community sufficient time to discover and report malicious releases. This delay is critical in reducing the window of vulnerability. How it Works: At its most basic, `safe-npm install` operates by reading the dependency list from your `package.json` file (or provided command-line arguments). It then queries the npm registry for all available versions of those dependencies. Critically, it filters those versions based on their publication age in relation to the configured minimum age. The new version that is both semantically compatible (as defined by your version constraints—e.g., `^18` for React) and at least 90 days old is selected and installed using npm. The output is stored in the package-lock.json, ensuring consistent builds. A dry-run feature allows a preview of what would be installed without making any changes. Configuration Options: * `--min-age-days <n>`: This is the primary configuration option, specifying the minimum number of days a package version must have been publicly available before it can be installed. The default value is 90 days, but can be adjusted based on project criticality and risk tolerance. Raising this value enhances security but might delay access to new features or bug fixes. Reducing this value balances risk and expediency. Intended Workflows: * Secure a New Project: When starting a new project, `safe-npm install` ensures that all dependencies are initially compliant with age requirements. Limitations: Philosophy: The development of safe-npm reflects a trade-off between security and expediency. The tool prioritizes protection against sudden supply chain compromises while acknowledging the potential for delayed feature access and bug fixes. It is one layer within a broader defense-in-depth strategy. The project also includes recommendations as a best practice for security: regular security audits (npm audit) , dependency review before adding new packages, monitoring for security advisories, using lock files, and using sandboxed or containerized environments. It's crucial to recognize that safe-npm isn't a silver bullet but a valuable addition to a thorough software security strategy. |