Code Security Auditor
Overview
This skill enables OpenCode to perform a comprehensive pre-execution security audit of a given codebase and produce a structured, high-signal risk report. It analyzes the entire project including source code, dependency manifests, build scripts, and configuration files from a security-first perspective.
When to Use This Skill
Use this skill when:
- User requests security analysis of a codebase
- User asks to "audit", "scan", or "check" code for safety before running
- User wants to know if code is safe to execute locally
- Analyzing untrusted or third-party code
- Performing due diligence on new dependencies or projects
Analysis Workflow
Step 1: Understand the Project Scope
- Identify the primary language and ecosystem (JavaScript/Node, Python, Go, Ruby, etc.)
- Locate all dependency manifests:
package.json, package-lock.json (Node.js)
requirements.txt, Pipfile, pyproject.toml (Python)
Gemfile, Gemfile.lock (Ruby)
go.mod, go.sum (Go)
Cargo.toml (Rust)
pom.xml, build.gradle, build.gradle.kts (Java/Kotlin)
- Identify entry points: main scripts, entry files, startup commands
Step 2: Perform Static Analysis
1. Dependencies Audit
Scan dependency manifests for:
- Known malicious or compromised packages (check known malware databases)
- Unmaintained packages (no recent updates, abandoned repos)
- Newly published packages (< 30 days) with high download counts
- Typosquatting risks (packages with similar names to popular libraries)
- Packages with install-time scripts (
preinstall, postinstall, prepare, prepublish)
Reference: Use references/package_checks.md for known suspicious packages and patterns.
2. Script Inspection
Examine all scripts for:
- Lifecycle hooks in manifest files (
postinstall, preinstall, prepare, prepublish)
- Shell execution patterns:
exec, spawn, backticks, system(), os.system(), subprocess calls
- Dynamic code execution:
eval(), Function(), setTimeout() with strings, pickle.loads(), unserialize()
- Encoded payloads: base64, hex, obfuscated strings, string concatenation
- Download and execute patterns: curl/wget piping to shell
3. File System Behavior
Detect operations that:
- Write outside the project directory
- Access sensitive paths:
~/.ssh, ~/.aws, /etc, /var, /proc, /sys
- Create hidden files: dotfiles in home directory, startup scripts
- Modify system configuration: cron, systemd services, launch agents
4. Network Activity
Identify:
- Hardcoded IP addresses (especially external)
- Hardcoded domains and endpoints
- Suspicious URL patterns: data exfiltration endpoints, command-and-control
- Unexpected ports or protocols
- DNS lookups or reverse IP queries
5. Obfuscation and Evasion
Flag:
- Minified or obfuscated code (especially in dependencies)
- Anti-debugging techniques: debugger detection, stack trace manipulation
- Dynamic imports:
import(), require() with variable paths
- Runtime code generation:
eval(), new Function(), createElement with strings
Step 3: Risk Assessment
For each finding, assess:
- Impact: What can happen if this code runs locally?
- Likelihood: How likely is this to be malicious vs. legitimate?
- Evidence: Specific file, line number, and code snippet
Potential Impact Categories
- File system compromise: Code that writes to arbitrary locations
- Credential theft: Access to SSH keys, environment variables, tokens, passwords
- Remote command execution: Network-enabled code execution capabilities
- Persistence: Cron jobs, startup scripts, systemd services, launch agents
- Privilege escalation: Code that requests or attempts to gain elevated privileges
- Data exfiltration: Network transmission of sensitive data
Step 4: Generate Structured Report
Produce output following the strict format in Output Format section.
Output Format
🔴 Critical Risks
Provide each critical risk with:
- Risk title: Brief descriptive title
- Evidence: File path, line number, specific code snippet
- Why it is dangerous: Technical explanation of the risk
- What to verify manually: Steps to confirm the finding
🟠 Suspicious Findings
Same structure as critical risks but lower severity.
🟡 Low Risk / Observations
Interesting findings that don't pose immediate danger but worth noting.
🔍 Manual Review Checklist
Provide actionable checklist items:
🚨 Indicators of Malicious Intent
List specific patterns that strongly indicate malicious code:
- Obfuscated code executing commands
- Suspicious network exfiltration
- Persistence mechanism installation
- Credential harvesting patterns
🧾 Final Verdict
Choose ONE and provide justification:
- SAFE TO RUN: No significant risks identified
- SAFE WITH SANDBOX ONLY: Risks exist but contained by sandbox
- HIGH RISK — DO NOT RUN: Significant malicious indicators found
Constraints
- DO NOT assume code is safe
- DO NOT execute any code
- DO NOT skip files
- Prefer false positives over false negatives
- Document all findings, even minor ones
Resources
scripts/
This skill does not require executable scripts.
references/
package_checks.md: Reference for known suspicious packages, malware patterns, and risky dependency indicators
assets/
This skill does not require assets.
1---2name: code-security-auditor3description: Perform pre-execution security audits of untrusted codebases through static analysis. Use when analyzing a codebase for potential malicious behavior, supply chain risks, or security vulnerabilities before local execution. Triggered by requests like "analyze this project for security risks", "audit this code before running", "check if this codebase is safe", or similar security review requests.4---56# Code Security Auditor78## Overview910This skill enables OpenCode to perform a comprehensive pre-execution security audit of a given codebase and produce a structured, high-signal risk report. It analyzes the entire project including source code, dependency manifests, build scripts, and configuration files from a security-first perspective.1112## When to Use This Skill1314Use this skill when:15- User requests security analysis of a codebase16- User asks to "audit", "scan", or "check" code for safety before running17- User wants to know if code is safe to execute locally18- Analyzing untrusted or third-party code19- Performing due diligence on new dependencies or projects2021## Analysis Workflow2223### Step 1: Understand the Project Scope24251. Identify the primary language and ecosystem (JavaScript/Node, Python, Go, Ruby, etc.)262. Locate all dependency manifests:27 - `package.json`, `package-lock.json` (Node.js)28 - `requirements.txt`, `Pipfile`, `pyproject.toml` (Python)29 - `Gemfile`, `Gemfile.lock` (Ruby)30 - `go.mod`, `go.sum` (Go)31 - `Cargo.toml` (Rust)32 - `pom.xml`, `build.gradle`, `build.gradle.kts` (Java/Kotlin)333. Identify entry points: main scripts, entry files, startup commands3435### Step 2: Perform Static Analysis3637#### 1. Dependencies Audit3839Scan dependency manifests for:40- Known malicious or compromised packages (check known malware databases)41- Unmaintained packages (no recent updates, abandoned repos)42- Newly published packages (< 30 days) with high download counts43- Typosquatting risks (packages with similar names to popular libraries)44- Packages with install-time scripts (`preinstall`, `postinstall`, `prepare`, `prepublish`)4546Reference: Use `references/package_checks.md` for known suspicious packages and patterns.4748#### 2. Script Inspection4950Examine all scripts for:51- Lifecycle hooks in manifest files (`postinstall`, `preinstall`, `prepare`, `prepublish`)52- Shell execution patterns: `exec`, `spawn`, backticks, `system()`, `os.system()`, `subprocess` calls53- Dynamic code execution: `eval()`, `Function()`, `setTimeout()` with strings, `pickle.loads()`, `unserialize()`54- Encoded payloads: base64, hex, obfuscated strings, string concatenation55- Download and execute patterns: curl/wget piping to shell5657#### 3. File System Behavior5859Detect operations that:60- Write outside the project directory61- Access sensitive paths: `~/.ssh`, `~/.aws`, `/etc`, `/var`, `/proc`, `/sys`62- Create hidden files: dotfiles in home directory, startup scripts63- Modify system configuration: cron, systemd services, launch agents6465#### 4. Network Activity6667Identify:68- Hardcoded IP addresses (especially external)69- Hardcoded domains and endpoints70- Suspicious URL patterns: data exfiltration endpoints, command-and-control71- Unexpected ports or protocols72- DNS lookups or reverse IP queries7374#### 5. Obfuscation and Evasion7576Flag:77- Minified or obfuscated code (especially in dependencies)78- Anti-debugging techniques: debugger detection, stack trace manipulation79- Dynamic imports: `import()`, `require()` with variable paths80- Runtime code generation: `eval()`, `new Function()`, `createElement` with strings8182### Step 3: Risk Assessment8384For each finding, assess:85- **Impact**: What can happen if this code runs locally?86- **Likelihood**: How likely is this to be malicious vs. legitimate?87- **Evidence**: Specific file, line number, and code snippet8889#### Potential Impact Categories9091- **File system compromise**: Code that writes to arbitrary locations92- **Credential theft**: Access to SSH keys, environment variables, tokens, passwords93- **Remote command execution**: Network-enabled code execution capabilities94- **Persistence**: Cron jobs, startup scripts, systemd services, launch agents95- **Privilege escalation**: Code that requests or attempts to gain elevated privileges96- **Data exfiltration**: Network transmission of sensitive data9798### Step 4: Generate Structured Report99100Produce output following the strict format in Output Format section.101102## Output Format103104### 🔴 Critical Risks105106Provide each critical risk with:107- **Risk title**: Brief descriptive title108- **Evidence**: File path, line number, specific code snippet109- **Why it is dangerous**: Technical explanation of the risk110- **What to verify manually**: Steps to confirm the finding111112### 🟠 Suspicious Findings113114Same structure as critical risks but lower severity.115116### 🟡 Low Risk / Observations117118Interesting findings that don't pose immediate danger but worth noting.119120### 🔍 Manual Review Checklist121122Provide actionable checklist items:123- [ ] Verify specific package legitimacy124- [ ] Check maintainer reputation125- [ ] Review network connections126- [ ] Audit file system operations127- etc.128129### 🚨 Indicators of Malicious Intent130131List specific patterns that strongly indicate malicious code:132- Obfuscated code executing commands133- Suspicious network exfiltration134- Persistence mechanism installation135- Credential harvesting patterns136137### 🧾 Final Verdict138139Choose ONE and provide justification:140- **SAFE TO RUN**: No significant risks identified141- **SAFE WITH SANDBOX ONLY**: Risks exist but contained by sandbox142- **HIGH RISK — DO NOT RUN**: Significant malicious indicators found143144## Constraints145146- DO NOT assume code is safe147- DO NOT execute any code148- DO NOT skip files149- Prefer false positives over false negatives150- Document all findings, even minor ones151152## Resources153154### scripts/155156This skill does not require executable scripts.157158### references/159160- `package_checks.md`: Reference for known suspicious packages, malware patterns, and risky dependency indicators161162### assets/163164This skill does not require assets.