openclaw-security-scanner
v1.0.0
Published
Security auditing and static analysis tool for OpenClaw skills
Maintainers
Readme
🔒 OpenClaw Security Scanner
Automated security auditing for OpenClaw skills - Detect vulnerabilities, dangerous patterns, and supply chain risks before deployment.
🎯 What It Does
Scans OpenClaw skills for security issues:
- 🔍 Static Code Analysis - Detect dangerous patterns (
eval,exec, unsafe deserialization) - 📦 Dependency Scanning - Check for known vulnerabilities in npm packages
- 🔐 Permission Auditing - Flag excessive tool access
- 🚫 Pattern Detection - Identify common security anti-patterns
- 📊 Risk Scoring - Quantify security posture
- 🔄 CI/CD Integration - Block unsafe deployments
🚀 Quick Start
Install
npm install -g openclaw-security-scannerScan a Skill
openclaw-security scanExample Output
🔒 OpenClaw Security Scanner v1.0.0
📂 Scanning: ./my-skill/
🔍 Static Analysis...
❌ CRITICAL: eval() usage detected in index.ts:42
⚠️ WARNING: exec() without input validation in utils.ts:15
✅ PASS: No unsafe deserialization
📦 Dependency Scan...
❌ CRITICAL: [email protected] (CVE-2021-23337)
⚠️ WARNING: [email protected] (CVE-2021-3749)
🔐 Permission Audit...
⚠️ WARNING: Broad file system access (Read/Write)
ℹ️ INFO: Network access detected
📊 Security Score: 45/100 (HIGH RISK)
Issues Found: 4 critical, 3 warnings, 1 info
Recommendation: DO NOT DEPLOY📖 Commands
openclaw-security scan [path]
Scan a skill directory:
openclaw-security scan ./my-skill
# Options:
# --output <file> Write report to file
# --format <json|html> Report format
# --fail-on <level> Exit code 1 if issues >= level (critical|high|medium)
# --fix Auto-fix safe issuesopenclaw-security check-deps
Audit dependencies only:
openclaw-security check-deps
# Checks:
# - Known vulnerabilities (CVE database)
# - Malicious packages
# - License compliance
# - Outdated packagesopenclaw-security patterns
Check for dangerous code patterns:
openclaw-security patterns --strict
# Detects:
# - eval(), Function(), new Function()
# - exec(), spawn(), child_process
# - Unsafe JSON.parse, YAML.load
# - SQL injection risks
# - XSS vectorsopenclaw-security permissions
Audit tool permissions:
openclaw-security permissions
# Flags:
# - Excessive file system access
# - Network requests to suspicious domains
# - Shell command execution
# - Sensitive data handlingopenclaw-security report
Generate detailed security report:
openclaw-security report --format html --output report.html🔍 Detection Rules
Critical Severity
eval()ornew Function()usage- Arbitrary command execution without validation
- Hardcoded credentials or API keys
- Known CVEs in dependencies (CVSS >= 9.0)
High Severity
child_process.exec()with user input- Unsafe deserialization (YAML.load, pickle)
- SQL queries with string concatenation
- File operations with unsanitized paths
- Known CVEs (CVSS 7.0-8.9)
Medium Severity
- Missing input validation
- Overly permissive file access
- HTTP requests without TLS
- Deprecated APIs
- Known CVEs (CVSS 4.0-6.9)
Low Severity / Info
- Code complexity warnings
- Missing error handling
- Performance anti-patterns
- Style violations
🛠️ Configuration
.openclaw-security.yml
version: 1
# Severity threshold (fail CI if exceeded)
failOn: high
# Rules to enable/disable
rules:
eval-usage: error
exec-usage: warn
hardcoded-secrets: error
unsafe-yaml: error
missing-validation: warn
# Allowlist for specific patterns
allow:
- pattern: 'Math.eval'
reason: 'Safe math expression evaluation'
- file: 'test/**/*.ts'
rule: '*'
reason: 'Tests can use unsafe patterns'
# Dependency scan config
dependencies:
allowVulnerabilities:
- CVE-2021-12345 # Acknowledged, will fix in next release
blockedPackages:
- dangerous-package
- known-malware
# Custom patterns (regex)
customPatterns:
- pattern: 'password\s*=\s*["\']'
severity: critical
message: 'Hardcoded password detected'🔌 CI/CD Integration
GitHub Actions
name: Security Scan
on: [push, pull_request]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Scanner
run: npm install -g openclaw-security-scanner
- name: Run Security Scan
run: openclaw-security scan --fail-on high --format json --output security-report.json
- name: Upload Report
uses: actions/upload-artifact@v3
with:
name: security-report
path: security-report.jsonGitLab CI
security-scan:
stage: test
script:
- npm install -g openclaw-security-scanner
- openclaw-security scan --fail-on high
artifacts:
reports:
sast: security-report.jsonPre-commit Hook
#!/bin/bash
# .git/hooks/pre-commit
openclaw-security scan --fail-on critical
if [ $? -ne 0 ]; then
echo "❌ Security scan failed. Fix issues before committing."
exit 1
fi📊 Security Score Calculation
Score = 100 - (weighted penalty sum)
| Severity | Penalty per Issue | |-----------|-------------------| | Critical | 30 points | | High | 15 points | | Medium | 5 points | | Low | 1 point |
Grades:
- 90-100: Excellent ✅
- 70-89: Good ⚠️
- 50-69: Fair ⚠️
- 0-49: Poor ❌ (DO NOT DEPLOY)
🎓 Examples
Example 1: Safe Skill
// ✅ Good: Input validation + safe APIs
import { validate } from './validator';
export async function handler(input, tools) {
const query = validate(input.query, { maxLength: 100 });
const results = await tools.web_search({ query });
return { results };
}Example 2: Unsafe Skill (BLOCKED)
// ❌ Bad: Multiple critical issues
export async function handler(input, tools) {
// CRITICAL: eval() usage
const result = eval(input.code);
// CRITICAL: Arbitrary command execution
await tools.exec({ command: input.userCommand });
// HIGH: Hardcoded credential
const apiKey = 'sk-1234567890abcdef';
return result;
}
// Security Score: 10/100 ❌ BLOCKEDExample 3: Fixed Skill
// ✅ Fixed version
import { VM } from 'vm2'; // Sandboxed eval alternative
export async function handler(input, tools) {
// Safe: Sandboxed execution
const vm = new VM({ timeout: 1000, sandbox: {} });
const result = vm.run(input.code);
// Safe: Validated command
const allowedCommands = ['ls', 'pwd', 'echo'];
if (!allowedCommands.includes(input.command)) {
throw new Error('Invalid command');
}
await tools.exec({ command: input.command });
// Safe: Environment variable
const apiKey = process.env.API_KEY;
return result;
}
// Security Score: 95/100 ✅🤝 Contributing
Contributions welcome! We need:
- [ ] More detection patterns
- [ ] CVE database integration
- [ ] Secret detection algorithms
- [ ] SARIF format support
- [ ] IDE extensions (VSCode, IntelliJ)
📄 License
MIT © Alex - Built for secure OpenClaw ecosystems
🔗 Links
Security first. Deploy with confidence. 🔒
