
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
GitHub Repository Security Analyzer — Scan repos for phishing, malware, and suspicious code before you run them
Don't run that repo! Scan GitHub repositories for phishing, malware, and suspicious code before you clone and run them.
A developer friend received a job opportunity on LinkedIn from someone pretending to be from a well-known tech company. They asked him to check out a GitHub repository — a seemingly normal coding exercise. Luckily, my friend reviewed the code first and found hidden data exfiltration, environment variable theft, and obfuscated payloads buried inside.
Not everyone is that careful. ghsafe is a CLI tool that scans any GitHub repository for malicious patterns before you run it, helping protect developers from:
# Run directly with npx (no install needed)
npx ghsafe scan https://github.com/user/suspicious-repo
# Or install globally
npm install -g ghsafe
npx ghsafe scan https://github.com/user/suspicious-repo
npx ghsafe scan ./path/to/project
# Recommended: Use GitHub Models (via your GitHub token)
export GITHUB_TOKEN=your-github-token
npx ghsafe scan https://github.com/user/repo --ai
# Alternative: Use OpenAI directly
export OPENAI_API_KEY=your-openai-key
npx ghsafe scan https://github.com/user/repo --ai
npx ghsafe scan ./project --json
| Category | Examples | Severity |
|---|---|---|
| Network Exfiltration | Webhook URLs, raw IP connections, tunneling services | 🟠 HIGH |
| Data Exfiltration | SSH key theft, env var collection, browser data access, crypto wallets | 🔴 CRITICAL |
| Code Obfuscation | eval(), Function(), Base64/hex payloads, String.fromCharCode | 🟠 HIGH |
| Dangerous Execution | child_process, shell commands, download-and-exec pipelines | 🔴 CRITICAL |
| Crypto Mining | Mining pool connections, known miner libraries, wallet addresses | 🔴 CRITICAL |
| Persistence | Crontab manipulation, shell profile modification, startup scripts | 🟠 HIGH |
| Suspicious Install Scripts | postinstall hooks that run code, download scripts | 🔴 CRITICAL |
ghsafe produces a rich terminal report with:
╭────────── 🛡️ ghsafe — Scan Report ──────────╮
│ │
│ Target: https://github.com/user/repo │
│ Scanned: 42 files │
│ Findings: 13 │
│ Risk Score: ████████████████████ 100/100 │
│ Verdict: 🚨 DANGEROUS │
│ │
╰──────────────────────────────────────────────╯
Category Summary
🟠 Network Exfiltration: 2 findings
🔴 Data Exfiltration: 3 findings
🟠 Code Obfuscation: 2 findings
🔴 Dangerous Execution: 3 findings
🔴 Crypto Mining: 1 finding
🟠 Persistence: 1 finding
🔴 Suspicious Install Scripts: 1 finding
When you enable the --ai flag, ghsafe sends a summary of the findings to an AI model for deeper contextual analysis.
ghsafe integrates natively with GitHub Models — using your existing GITHUB_TOKEN to access AI models through GitHub's infrastructure. No additional API keys needed if you already have a GitHub token.
export GITHUB_TOKEN=your-github-token
npx ghsafe scan https://github.com/user/repo --ai
If GITHUB_TOKEN is not set, ghsafe falls back to OpenAI directly.
export OPENAI_API_KEY=your-openai-key
npx ghsafe scan https://github.com/user/repo --ai
AI analysis helps:
Note: AI analysis is optional. The basic static scan works without any API keys or tokens.
src/
├── index.ts # CLI entry point (Commander.js)
├── scanner/
│ ├── static.ts # Static pattern scanner engine
│ ├── ai.ts # AI-powered analysis (OpenAI)
│ └── rules/
│ ├── network.ts # Network exfiltration rules
│ ├── obfuscation.ts # Code obfuscation rules
│ ├── exfiltration.ts# Data theft rules
│ ├── execution.ts # Dangerous execution rules
│ ├── crypto.ts # Crypto mining rules
│ ├── persistence.ts # Persistence mechanism rules
│ ├── install-scripts.ts # Suspicious install scripts
│ └── index.ts # Rule registry
├── repo/
│ ├── loader.ts # GitHub URL cloning / local path loading
│ └── file-walker.ts # Directory traversal with filtering
├── report/
│ ├── renderer.ts # Rich terminal output
│ └── types.ts # TypeScript type definitions
└── utils/
└── config.ts # Configuration constants
| Code | Meaning |
|---|---|
0 | Repository is safe |
1 | Suspicious patterns found |
2 | Dangerous patterns detected |
This makes ghsafe easy to integrate into CI/CD pipelines.
MIT — see LICENSE
Built with ❤️ and 🛡️ to protect developers from malicious repositories.
FAQs
GitHub Repository Security Analyzer — Scan repos for phishing, malware, and suspicious code before you run them
The npm package ghsafe receives a total of 4 weekly downloads. As such, ghsafe popularity was classified as not popular.
We found that ghsafe demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.