Version: 0.1 Status: Draft for MVP Execution Product Type: Developer Security CLI, Local Package Firewall, AI-Agent Supply Chain Guardrail Primary Users: Developers, Platform Engineering Teams, AppSec Teams, DevSecOps Teams, AI Coding Agent Users Initial Ecosystem: npm Expansion Ecosystems: PyPI, Go Modules, Maven, NuGet
Modern software development increasingly depends on open-source packages, AI-generated code suggestions, automated dependency installation, and fast-moving developer workflows. This creates a rapidly expanding software supply chain attack surface.
Malicious packages, typosquatting, dependency confusion, lifecycle-script abuse, credential theft, and AI-hallucinated package names are now practical attack paths. Many existing tools focus on CVE scanning, repository dashboards, SBOM generation, or CI/CD-time detection. These are useful, but they often detect risk after a package has already entered the developer environment, source repository, or pipeline.
PkgSafe is a local-first, developer-friendly package security agent that validates packages before installation. It acts as a portable package firewall for developers and AI coding agents.
The MVP will start with npm and provide a CLI that can inspect packages, detect lifecycle scripts, flag suspicious install behavior, identify typosquatting risk, score package trust, and return a clear allow, warn, or block decision.
The strategic differentiator is the combination of:
- Pre-install package validation
- Local-first and offline-friendly execution
- Developer-friendly CLI workflow
- MCP-compatible interface for AI coding agents
- Future isolated behavior analysis
- Human-readable risk explanations
PkgSafe should become the default local security layer between developers, AI coding agents, package registries, and dependency installation commands.
The long-term vision is:
A portable developer security agent that prevents malicious, hallucinated, typosquatted, or suspicious open-source packages from entering developer machines, repositories, CI/CD systems, and enterprise software supply chains.
PkgSafe should not replace enterprise SCA platforms. Instead, it should complement them by operating earlier in the workflow: before package installation.
PkgSafe is a local-first package firewall that protects developers and AI coding agents from malicious or suspicious open-source dependencies before installation.
PkgSafe validates packages before they are installed by analyzing registry metadata, lifecycle scripts, package reputation, typosquat risk, credential exposure patterns, known vulnerability intelligence, and future isolated behavior analysis. It provides clear allow/warn/block decisions through a CLI, JSON API, CI/CD integration, and MCP tools for AI coding agents.
PkgSafe belongs to an emerging product category:
Pre-Install Software Supply Chain Security
Related categories:
- Software Composition Analysis
- Package Firewall
- Developer Security Tooling
- AI Coding Agent Guardrails
- Open-Source Dependency Trust Scoring
- DevSecOps Shift-Left Controls
Developers install packages quickly, often based on documentation snippets, Stack Overflow answers, AI-generated code, or package search results. This creates several risks:
- A malicious package may execute during installation.
- A typosquatted package may mimic a popular package.
- An AI coding assistant may suggest a non-existent or hallucinated package name.
- An attacker may register that hallucinated package name.
- Lifecycle scripts may read credentials, tokens, SSH keys,
.envfiles, or cloud configuration files. - CVE scanners may not detect malicious intent because the package may not have a known vulnerability.
- Enterprise tools often detect risk after dependency files are already committed.
- Developers ignore tools that generate noisy, non-actionable dashboard alerts.
The core problem:
Developers need a fast, local, explainable package safety decision before installing a dependency.
Needs:
- Avoid installing suspicious packages.
- Get simple explanations.
- Continue working without excessive friction.
- Use one command instead of learning complex security tools.
Example:
pkgsafe scan-npm-package axiosThis user works with Cursor, Claude Code, Codex, Copilot, Gemini Code Assist, or other AI coding assistants.
Needs:
- Validate AI-suggested packages before installation.
- Detect hallucinated package names.
- Identify suspicious new packages.
- Prevent agentic tools from installing unsafe dependencies automatically.
Example:
An AI agent wants to install:
npm install react-auth-mongodb-adapter-proPkgSafe should flag whether the package appears legitimate, suspicious, or hallucinated.
Needs:
- Provide standard developer guardrails.
- Reduce dependency supply chain risk.
- Avoid central bottlenecks.
- Define policies that work across teams.
- Integrate with existing CI/CD and developer workflows.
Needs:
- Detect malicious package risk early.
- Reduce noisy SCA findings.
- Enforce policy selectively.
- Produce evidence for blocked or approved dependencies.
- Integrate with GitHub Actions and developer workflows.
Needs:
- Organization-wide package policy.
- Allowlist and denylist controls.
- Private registry support.
- Air-gapped package intelligence.
- Audit trails and governance evidence.
- Integration points for downstream security tooling.
A developer wants to install an npm package.
pkgsafe scan-npm-package lodashPkgSafe returns:
- Package name
- Version
- Risk score
- Decision
- Reasons
- Recommended action
A developer installs through PkgSafe.
pkgsafe npm install axiosPkgSafe checks the package first. If allowed, it delegates to npm. If suspicious, it warns or blocks depending on policy.
A developer or CI job scans an existing lockfile.
pkgsafe scan-lockfile package-lock.jsonPkgSafe identifies suspicious direct or transitive dependencies.
An AI coding agent calls PkgSafe through MCP before suggesting or installing a package.
Example MCP request:
{
"ecosystem": "npm",
"name": "next-auth-mongodb-adapter-pro",
"version": "latest",
"requested_by": "ai_agent"
}PkgSafe returns:
{
"decision": "warn",
"risk_score": 72,
"reasons": [
"Package was recently published",
"No linked source repository",
"Name resembles AI-generated package naming pattern",
"Low ecosystem reputation"
]
}A package contains a postinstall script that runs curl.
PkgSafe should detect:
- Lifecycle script exists
- Network command exists
- Credential-related strings exist
- Obfuscation exists
- Suspicious process execution exists
Decision should be warn or block depending on severity.
A package attempts to read:
~/.aws/credentials
~/.ssh/id_rsa
.env
.npmrc
PkgSafe should block the package when behavior analysis is enabled.
Build a working npm-focused CLI that can scan real npm packages before installation and return explainable risk decisions.
Recommended product structure:
- Product: Niyam Guard
- CLI: pkgsafe
- Module: Package Safety Agent
This allows future integration into the broader Niyam governance platform while keeping the CLI simple and developer-friendly.
The MVP should support:
pkgsafe scan-npm-package <package-name>
pkgsafe scan-npm-package <package-name> --version <version>
pkgsafe scan-npm-package <package-name> --json
pkgsafe scan-local-npm <path>
pkgsafe scan-lockfile <path-to-package-lock.json>
pkgsafe explain <package-name>
pkgsafe update-db
pkgsafe mcp serve
pkgsafe versionPkgSafe must fetch package metadata from the npm registry.
Required metadata:
- Package name
- Latest version
- Selected version
- Tarball URL
- Maintainers
- Repository URL
- Publish time
- License
- Description
- Dependencies
- Scripts
- Dist integrity
- Download metadata if available
PkgSafe must download the selected npm package tarball into a local cache.
Requirements:
- Avoid repeated downloads for the same package/version.
- Verify tarball integrity when metadata includes integrity hash.
- Store package tarballs under PkgSafe cache directory.
- Support cache cleanup later.
PkgSafe must safely extract npm tarballs into a temporary directory.
Requirements:
- Prevent path traversal.
- Prevent overwriting files outside temp directory.
- Locate
package/package.json. - Handle invalid tarballs safely.
- Delete temp files after scan unless debug mode is enabled.
PkgSafe must inspect package.json.
Signals to detect:
preinstallinstallpostinstallpreparescriptscontaining suspicious command patterns- Missing repository metadata
- Missing license
- New or unknown package
- Credential-related references
- Shell execution
- Network tools
- Encoded or obfuscated script patterns
Suspicious patterns:
curl
wget
Invoke-WebRequest
powershell
bash -c
sh -c
eval
base64
atob
child_process
exec
spawn
.env
.npmrc
.aws
.ssh
.kube
token
secret
credential
metadata.google.internal
169.254.169.254
PkgSafe must generate a deterministic risk score.
Score range:
0-29 Allow
30-69 Warn
70-100 Block or High-Risk Warn
Initial scoring model:
| Signal | Suggested Score |
|---|---|
| Known malicious package | 100 |
| Reads credential path | 100 |
| Lifecycle script exists | +20 |
| Lifecycle script uses network command | +30 |
| Lifecycle script references secrets | +40 |
| Obfuscation detected | +25 |
| Missing repository | +10 |
| Missing license | +5 |
| Package recently published | +15 |
| Low package maturity | +10 |
| Typosquat risk | +25 |
| No maintainers or suspicious maintainer metadata | +20 |
| Known trusted package | -20 |
Decision must include explainable reasons.
Human-readable output:
Decision: WARN
Package: npm/example-package@1.2.3
Risk Score: 61/100
Reasons:
- Package defines a postinstall script
- Lifecycle script uses curl
- Package metadata does not include a source repository
Recommended Action:
Review package before installing.
JSON output:
{
"ecosystem": "npm",
"package": "example-package",
"version": "1.2.3",
"decision": "warn",
"risk_score": 61,
"reasons": [
"Package defines a postinstall script",
"Lifecycle script uses curl",
"Package metadata does not include a source repository"
]
}PkgSafe must maintain a local cache.
Initial cache format can be JSON. MVP+ should move to SQLite.
Cache should store:
- Package metadata
- Tarball path
- Scan result
- Scan timestamp
- Risk decision
- Reasons
- Threat DB version
- Policy version
PkgSafe must expose an MCP-compatible server for AI coding agents.
Initial tool:
validate_package_install
Input:
{
"ecosystem": "npm",
"name": "package-name",
"version": "latest",
"requested_by": "human|ai_agent"
}Output:
{
"decision": "allow|warn|block",
"risk_score": 0,
"reasons": [],
"safe_alternatives": []
}Future MCP tools:
explain_package_risk
score_lockfile
suggest_safe_alternative
validate_install_command
generate_dependency_policy
PkgSafe should feel fast enough for developer workflows.
Targets:
| Operation | Target |
|---|---|
| Cached metadata scan | Under 500 ms |
| Fresh metadata scan | Under 3 seconds |
| Tarball download and scan | Under 10 seconds for normal package |
| Lockfile scan | Under 15 seconds for typical app |
| MCP response from cache | Under 300 ms |
PkgSafe should ship as a single binary where possible.
Supported platforms:
| Platform | MVP |
|---|---|
| Linux amd64 | Required |
| macOS amd64 | Required |
| macOS arm64 | Required |
| Windows amd64 | Required, scanner only |
| Linux arm64 | Future |
PkgSafe should be local-first.
Principles:
- Do not upload source code by default.
- Do not upload package manifests by default.
- Do not upload dependency graphs by default.
- Do not send developer environment data to cloud services.
- Make telemetry opt-in only.
- Enterprise policy sync should be explicit.
PkgSafe must be secure by design.
Requirements:
- Safe tarball extraction
- No execution of untrusted lifecycle scripts in MVP static scan
- Isolated behavior execution only in later phase
- Strict timeout controls
- No default access to host credentials during isolated behavior runs
- Clear policy decision logging
- Tamper-resistant release artifacts
- Checksums for binaries
- Signed releases in later phase
Every decision must include reasons.
Bad output:
Blocked due to high risk.
Good output:
Blocked because the postinstall script references ~/.aws/credentials and executes curl.
The following should not be built in the first MVP:
- SaaS dashboard
- Enterprise backend
- Full IDE extension
- PyPI support
- Go Modules support
- Maven support
- NuGet support
- ML-based detection
- Registry proxy
- Private registry firewall
- Full isolated behavior execution
- Organization-wide policy sync
- Security tooling integration interfaces
Command:
pkgsafe scan-npm-package lodashOutput:
Decision: ALLOW
Package: npm/lodash@4.17.21
Risk Score: 12/100
Reasons:
- No lifecycle install scripts detected
- Repository metadata exists
- Package is mature and widely used
Command:
pkgsafe scan-npm-package react-markdown-renderer-plusOutput:
Decision: WARN
Package: npm/react-markdown-renderer-plus@1.0.1
Risk Score: 68/100
Reasons:
- Package was recently published
- Package metadata does not include a source repository
- Package name resembles common AI-generated package naming
- Package has low ecosystem reputation
Recommended Action:
Review before installing. Consider established alternatives.
Command:
pkgsafe scan-npm-package suspicious-packageOutput:
Decision: BLOCK
Package: npm/suspicious-package@1.0.0
Risk Score: 100/100
Reasons:
- Package defines a postinstall script
- Lifecycle script references ~/.aws/credentials
- Lifecycle script executes curl
- Script appears designed to access credential material
Recommended Action:
Do not install this package.
| Metric | Target |
|---|---|
| GitHub stars | 500+ in early launch |
| CLI installs/downloads | 1,000+ in first 60 days |
| Repeat users | 30%+ |
| MCP setup users | 100+ early adopters |
| GitHub Action users | 100+ repos |
| Metric | Target |
|---|---|
| False positive rate on popular packages | Below 5% |
| Scan success rate | Above 95% |
| Cached scan response | Under 500 ms |
| Fresh npm package scan | Under 10 seconds |
| Test coverage for core packages | Above 70% |
| Metric | Target |
|---|---|
| Credential-reading test packages blocked | 100% |
| Known malicious packages blocked | 100% |
| Suspicious lifecycle scripts flagged | Above 90% |
| Typosquat candidates warned | Above 80% |
| Safe common packages allowed | Above 95% |
Developer / AI Agent
|
v
PkgSafe CLI / MCP Server
|
v
Package Resolver
|
+--> npm Registry Metadata Fetcher
+--> Tarball Downloader
+--> Lockfile Parser
|
v
Analyzer Layer
|
+--> Static Analyzer
+--> Typosquat Analyzer
+--> Trust Analyzer
+--> Vulnerability Analyzer
+--> Sandbox Analyzer
|
v
Risk Engine
|
v
Decision Engine
|
+--> Allow
+--> Warn
+--> Block
|
v
Output Layer
|
+--> Human Output
+--> JSON
+--> SARIF
+--> MCP Response
pkgsafe/
cmd/
pkgsafe/
main.go
internal/
cli/
config/
db/
registry/
npm/
pypi/
analyzer/
npm/
static/
behavior/
typosquat/
trust/
vulnerability/
cache/
mcp/
output/
policy/
risk/
types/
rules/
default-policy.yaml
credential-paths.yaml
suspicious-patterns.yaml
testdata/
npm/
safe-package/
postinstall-network/
reads-credentials/
typosquat/
docs/
architecture.md
threat-model.md
mcp-usage.md
roadmap.md
enterprise.md
scripts/
package.sh
.github/
workflows/
ci.yml
release.yml
README.md
Makefile
go.mod
PkgSafe should support a YAML policy file.
Example:
mode: warn
thresholds:
allow_max_score: 29
warn_max_score: 69
block_min_score: 70
protected_paths:
- "~/.aws"
- "~/.azure"
- "~/.gcp"
- "~/.ssh"
- "~/.kube"
- "~/.npmrc"
- "~/.pypirc"
- ".env"
- ".env.local"
- ".vault-token"
trusted_packages:
npm:
- lodash
- axios
- react
- express
blocked_packages:
npm: []
rules:
lifecycle_script_present:
severity: medium
score: 20
network_command_in_lifecycle:
severity: high
score: 30
credential_path_reference:
severity: critical
score: 100
typosquat_candidate:
severity: high
score: 25
missing_repository:
severity: low
score: 10PkgSafe must follow these principles:
- Local-first by default
- No source code upload by default
- No telemetry without opt-in
- Explain every decision
- Do not execute untrusted package scripts unless a real isolated backend is active
- Never expose real developer credentials to package scripts
- Prefer warning over blocking unless risk is clear
- Enterprise policies must be transparent to developers
- Cache results for speed
- Fail safely when package metadata is incomplete
| Risk | Mitigation |
|---|---|
| False positives frustrate developers | Default to warn mode and provide clear reasons |
| Isolated behavior support is hard cross-platform | Start with static scan, then a real isolated backend |
| Enterprise tools already exist | Position as pre-install local firewall, not SCA replacement |
| npm metadata can be incomplete | Use multiple signals, not one signal |
| AI hallucination detection is imperfect | Start with heuristics and reputation scoring |
| Registry rate limits | Use local cache |
| Developers bypass tool | Make CLI fast and useful |
| MCP clients vary | Keep MCP server simple and well-documented |
The MVP is successful when:
pkgsafe scan-npm-package <name>works for real npm packages.pkgsafe scan-local-npm <path>works for local package folders.pkgsafe scan-lockfile package-lock.jsonworks for npm lockfiles.- CLI returns
allow,warn, orblock. - CLI explains every decision.
- JSON output is available.
- Lifecycle scripts are detected.
- Suspicious script patterns are detected.
- Typosquat candidates are warned.
- MCP
validate_package_installreturns package safety decision. - Tests pass in CI.
- Release binaries are generated for Linux, macOS, and Windows.