Back to skill

Security audit

Code Security Auditor

Security checks for vulnerabilities and agentic risk

Overview

This security scanner is mostly purpose-aligned, but it overstates local privacy while including remote LLM paths and a script that writes persistent agent learning state.

Install only if you are comfortable with a Review-level security tool: use the default local scanner path for sensitive repositories, avoid enabling Qwen or ChatGLM unless you intentionally want source-derived prompts sent to those providers, and do not run iterate.sh unless you accept writes to shared OpenClaw learning state.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Error
Location
llm_integration.py:47
Finding
Optional Remote LLM Providers Transmit Source Code and Security Finding Data Contrary to Local-Only Privacy Claims## Vulnerability Details **File Location**: `llm_integration.py:47-49`, `llm_integration.py:79-94`, `llm_integration.py:140-154`, `llm_integration.py:207-229`, and `llm_integration.py:235-253` **Vulnerability Type**: Sensitive source-code and security-data disclosure to third-party LLM services **Risk Level**: High ### Vulnerable Code The vulnerability-analysis method incorporates source code and context into an LLM prompt: ```python prompt = self._build_vulnerability_analysis_prompt(code, vuln_type, context) response = self._call_llm(prompt) return self._parse_vulnerability_analysis(response) ``` The generated prompt includes the supplied source-code content: ```python return f"""You are a professional code security auditor. Analyze whether the following code contains a {vuln_type} vulnerability. ## Code Snippet ```python {code} ``` ## Context {context if context else "No additional context"} """ ``` Finding analysis similarly incorporates evidence and surrounding code: ```python return f"""Analyze whether the following security warning is a false positive. ## Finding - Type: {finding.get('type', 'unknown')} - File: {finding.get('location', {}).get('file', 'unknown')} - Line: {finding.get('location', {}).get('line', 0)} - Evidence: {finding.get('evidence', '')} ## Code Context {finding.get('context', 'No context')} """ ``` The Qwen provider sends the resulting prompt to Alibaba DashScope: ```python def _call_qwen(self, prompt: str) -> str: url = "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation" headers = { "Authorization": f"Bearer {self.config.api_key}", "Content-Type": "application/json" } payload = { "model": self.config.model, "input": { "messages": [ {"role": "user", "content": prompt} ] }, "parameters": { ...[truncated 3412 chars]
Remediation
## Remediation Suggestions 1. Remove unconditional claims that all processing is local and that source code never leaves the environment. 2. Clearly identify Ollama as local and Qwen/ChatGLM as remote providers in `SKILL.md`, `README.md`, and `skill.yaml`. 3. Require explicit informed consent before enabling any remote provider. 4. Display the destination, categories of transmitted data, and applicable privacy implications before the first remote request. 5. Redact secrets before prompt construction, including API keys, passwords, bearer tokens, private keys, cloud credentials, and scanner evidence. 6. Minimize prompts to the smallest source fragment required for analysis. 7. Add an egress-disabled configuration that is enabled by default. 8. Enforce an allowlist of approved HTTPS destinations and reject arbitrary base URLs for remote operation. 9. Add tests proving that remote requests cannot occur without explicit opt-in and that sensitive evidence is removed before transmission. 10. Consider separating remote-provider support into an optional package so that a local-only installation has no external analysis path.

T02 · Agent Memory Poisoning

Warning
Location
iterate.sh:330
Finding
Iteration Script Persistently Modifies Shared Agent Learning State Outside the Skill Directory## Vulnerability Details **File Location**: `iterate.sh:330-363` **Vulnerability Type**: Unscoped persistent modification of global Agent state **Risk Level**: Medium ### Vulnerable Code The script selects a global learning file outside the project and appends persistent assessment content to it: ```bash LEARNINGS_FILE="/root/.openclaw/workspace/.learnings/LEARNINGS.md" mkdir -p "$(dirname "$LEARNINGS_FILE")" cat >> "$LEARNINGS_FILE" << EOF ## [$(date '+%Y%m%d-%H%M%S')] code_security_auditor_assessment **Logged**: $(date '+%Y-%m-%dT%H:%M:%S+08:00') **Priority**: medium **Status**: pending **Area**: security ### Summary Code Security Auditor autonomous iteration assessment completed. ### Details - Score: $TOTAL_SCORE / $MAX_SCORE ($PERCENTAGE%) - Grade: $GRADE - Improvement suggestions: ${#IMPROVEMENTS[@]} ### Suggested Action Continue with the generated improvement recommendations. ### Metadata - Source: auto_evolution - Skill: code-security-auditor - Score: $PERCENTAGE - Related Files: \`$SKILL_DIR/\` --- EOF ``` ### Technical Analysis Running `iterate.sh` creates or modifies `/root/.openclaw/workspace/.learnings/LEARNINGS.md`, which is outside the Skill’s own project and report directories. The appended record includes a persistent suggested action intended for later consumption. Writing audit reports under the Skill directory is consistent with an iteration tool. Modifying a shared, cross-session Agent learning file is not necessary to perform code auditing or evaluate scanner quality and exceeds the minimum filesystem scope required by the declared functionality. The current appended values are locally generated assessment data, and the reviewed version does not place an identified attacker-controlled payload into the file. Consequently, this is a persistent state-boundary violation and a potential memory-poisoning channel rather than evidence of an active malicious instructio ...[truncated 1425 chars]
Remediation
## Remediation Suggestions 1. Remove the automatic write to `/root/.openclaw/workspace/.learnings/LEARNINGS.md`. 2. Store iteration results only under the Skill-owned `iteration-reports` directory. 3. Require explicit user confirmation before writing to any shared or persistent Agent state. 4. If learning integration is required, use a documented API with per-Skill namespaces and least-privilege authorization. 5. Store structured observations rather than behavioral instructions such as suggested future actions. 6. Validate and escape every value before persistence if any value may later originate from project content or external tools. 7. Add a configuration option that disables global learning integration by default. 8. Add tests ensuring routine auditing and iteration cannot modify files outside an explicitly authorized output directory. 9. Record the destination and exact data being persisted in user-facing documentation.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Output HandlingUnvalidated Output Injection, Cross-Context Output, Unbounded Output
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
Findings (62)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
This finding alleges undeclared network egress and overclaims about implemented scanning features. If the skill sends analyzed code or findings to external or local LLM services without clear disclosure and consent, it can expose proprietary code, secrets, and vulnerability data outside the user's environment.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding
This finding alleges undeclared network egress and overclaims about implemented scanning features. If the skill sends analyzed code or findings to external or local LLM services without clear disclosure and consent, it can expose proprietary code, secrets, and vulnerability data outside the user's environment.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
This finding alleges undeclared network egress and overclaims about implemented scanning features. If the skill sends analyzed code or findings to external or local LLM services without clear disclosure and consent, it can expose proprietary code, secrets, and vulnerability data outside the user's environment.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 检查敏感文件权限
chmod 600 .env          # ✅
chmod 644 config.yaml   # ✅
chmod 755 scripts/      # ✅
chmod 777 anything      # ❌ 禁止
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
```bash
# 检查敏感文件权限
chmod 600 .env          # ✅
chmod 644 config.yaml   # ✅
chmod 755 scripts/      # ✅
chmod 777 anything      # ❌ 禁止
Confidence
80% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Description-Behavior Mismatch

High
Confidence
97% confidence
Finding
The documentation claims the tool runs fully locally and keeps code in-environment, but later states audit results are fed back to an AI model for continual learning. That contradiction can mislead users into exposing sensitive code-derived findings, secrets, or internal architecture details under a false privacy guarantee.

Intent-Code Divergence

High
Confidence
95% confidence
Finding
This is the same core issue as SDI-1: the skill markets itself as local/private while also describing feedback of audit outputs to an AI model. In a security-audit context, this is more dangerous because findings often contain sensitive source snippets, dependency inventories, and exploit paths.

Credential Access

High
Category
Privilege Escalation
Content
dirs[:] = [d for d in dirs if d not in ['.git', 'node_modules', 'venv', '__pycache__', 'dist', 'build']]
        
        for file in files:
            if file.endswith(('.py', '.js', '.ts', '.jsx', '.tsx', '.json', '.yaml', '.yml', '.env', '.config')):
                filepath = os.path.join(root, file)
                try:
                    with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Unvalidated Output Injection

High
Category
Output Handling
Content
**JavaScript (React)**:
```jsx
// Before
<div dangerouslySetInnerHTML={{__html: userContent}} />

// After
<div>{userContent}</div>  // React 默认转义
Confidence
65% confidence
Finding
Model output is used without validation or sanitization. Unvalidated output injected into downstream contexts (SQL, shell, HTML) enables injection attacks and arbitrary code execution.

Cloud Metadata Access

High
Category
Server-Side Request Forgery
Content
# 检查云元数据 IP
        cloud_metadata_ips = [
            '169.254.169.254',  # AWS
            '100.100.100.200',  # Alibaba
            '168.63.129.16',    # Azure
        ]
        if str(ip_obj) in cloud_metadata_ips:
Confidence
85% confidence
Finding
Code accesses a cloud instance metadata endpoint (e.g. 169.254.169.254). A single request can return temporary IAM credentials, making this a high-value SSRF target for credential theft.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
| A03-003 | SQL 注入 format | `execute("SELECT...%s" % var)` | CRITICAL |
| A03-004 | NoSQL 注入 | `collection.find({"$where": var})` | CRITICAL |
| A03-005 | 命令注入 os.system | `os.system(f"cmd {var}")` | CRITICAL |
| A03-006 | 命令注入 subprocess | `subprocess.call(var, shell=True)` | CRITICAL |
| A03-007 | 命令注入 eval | `eval(user_input)` | CRITICAL |
| A03-008 | 命令注入 exec | `exec(user_input)` | CRITICAL |
| A03-009 | LDAP 注入 | `ldap.search(filter=var)` | HIGH |
Confidence
80% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Cloud Metadata Access

High
Category
Server-Side Request Forgery
Content
| A05-017 | 测试文件未删除 | `/test`, `/demo` | MEDIUM |
| A05-018 | Swagger 未保护 | `/swagger`, `/api-docs` | MEDIUM |
| A05-019 | 监控面板暴露 | `/metrics`, `/grafana` | HIGH |
| A05-020 | 云元数据暴露 | 169.254.169.254 可访问 | CRITICAL |

---
Confidence
90% confidence
Finding
Code accesses a cloud instance metadata endpoint (e.g. 169.254.169.254). A single request can return temporary IAM credentials, making this a high-value SSRF target for credential theft.

Cloud Metadata Access

High
Category
Server-Side Request Forgery
Content
| A05-017 | 测试文件未删除 | `/test`, `/demo` | MEDIUM |
| A05-018 | Swagger 未保护 | `/swagger`, `/api-docs` | MEDIUM |
| A05-019 | 监控面板暴露 | `/metrics`, `/grafana` | HIGH |
| A05-020 | 云元数据暴露 | 169.254.169.254 可访问 | CRITICAL |

---
Confidence
90% confidence
Finding
Code accesses a cloud instance metadata endpoint (e.g. 169.254.169.254). A single request can return temporary IAM credentials, making this a high-value SSRF target for credential theft.

Cloud Metadata Access

High
Category
Server-Side Request Forgery
Content
| A05-017 | 测试文件未删除 | `/test`, `/demo` | MEDIUM |
| A05-018 | Swagger 未保护 | `/swagger`, `/api-docs` | MEDIUM |
| A05-019 | 监控面板暴露 | `/metrics`, `/grafana` | HIGH |
| A05-020 | 云元数据暴露 | 169.254.169.254 可访问 | CRITICAL |

---
Confidence
90% confidence
Finding
Code accesses a cloud instance metadata endpoint (e.g. 169.254.169.254). A single request can return temporary IAM credentials, making this a high-value SSRF target for credential theft.

Cloud Metadata Access

High
Category
Server-Side Request Forgery
Content
| A05-017 | 测试文件未删除 | `/test`, `/demo` | MEDIUM |
| A05-018 | Swagger 未保护 | `/swagger`, `/api-docs` | MEDIUM |
| A05-019 | 监控面板暴露 | `/metrics`, `/grafana` | HIGH |
| A05-020 | 云元数据暴露 | 169.254.169.254 可访问 | CRITICAL |

---
Confidence
90% confidence
Finding
Code accesses a cloud instance metadata endpoint (e.g. 169.254.169.254). A single request can return temporary IAM credentials, making this a high-value SSRF target for credential theft.

Cloud Metadata Access

High
Category
Server-Side Request Forgery
Content
| A05-017 | 测试文件未删除 | `/test`, `/demo` | MEDIUM |
| A05-018 | Swagger 未保护 | `/swagger`, `/api-docs` | MEDIUM |
| A05-019 | 监控面板暴露 | `/metrics`, `/grafana` | HIGH |
| A05-020 | 云元数据暴露 | 169.254.169.254 可访问 | CRITICAL |

---
Confidence
90% confidence
Finding
Code accesses a cloud instance metadata endpoint (e.g. 169.254.169.254). A single request can return temporary IAM credentials, making this a high-value SSRF target for credential theft.

Cloud Metadata Access

High
Category
Server-Side Request Forgery
Content
| A05-017 | 测试文件未删除 | `/test`, `/demo` | MEDIUM |
| A05-018 | Swagger 未保护 | `/swagger`, `/api-docs` | MEDIUM |
| A05-019 | 监控面板暴露 | `/metrics`, `/grafana` | HIGH |
| A05-020 | 云元数据暴露 | 169.254.169.254 可访问 | CRITICAL |

---
Confidence
90% confidence
Finding
Code accesses a cloud instance metadata endpoint (e.g. 169.254.169.254). A single request can return temporary IAM credentials, making this a high-value SSRF target for credential theft.

Credential Access

High
Category
Privilege Escalation
Content
| A10-017 | 内部服务调用 | 内网 API 可访问 | HIGH |
| A10-018 | Redis 未授权 | 内网 Redis 可访问 | CRITICAL |
| A10-019 | MongoDB 未授权 | 内网 MongoDB 可访问 | CRITICAL |
| A10-020 | 文件读取 | `file:///etc/passwd` | CRITICAL |

---
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

os.system() or os exec-family call

High
Category
Dangerous Code Execution
Content
# 🟠 HIGH: 命令注入
def ping_host(host):
    # 危险:os.system 直接执行用户输入
    os.system(f"ping -c 4 {host}")

# 🟠 HIGH: 弱加密
import hashlib
Confidence
99% confidence
Finding
This is a true command injection risk because untrusted input is interpolated into a shell command and executed via os.system. An attacker controlling host could inject shell metacharacters and execute arbitrary commands on the server, leading to full system compromise depending on process privileges.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
该 markdown 文件整体以中文编写,包括标题、目录、流程说明和示例,但未说明这是面向中文社区的特定版本,也未提供其他语言选项或用户选择机制。根据语言/区域政策,未经用户选择而默认强制单一语言属于自然语言层面的策略问题。

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
The entire skill-facing report is written in Chinese, including headings, conclusions, recommendations, and production-readiness statements, with no indication that the user can choose another language. Per the policy, enforcing a specific language without opt-in is a natural-language locale violation unless the constraint is explicitly justified as region-specific.

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
SQP-3 applies to all file types and covers language or locale policy violations in natural-language content. This file presents the skill materials exclusively in Chinese beginning at the title and later recommends it for production and enterprise compliance use, but does not offer users a language choice or explain that the skill is intentionally limited to a Chinese-language audience.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The primary descriptive content is presented in Chinese, including core claims about the tool, with no indication that other languages are supported or that Chinese is required for a region-specific purpose. The policy specifically flags language or locale constraints when they are imposed without user opt-in.

Description-Behavior Mismatch

Medium
Confidence
85% confidence
Finding
The README makes a strong privacy/security claim that the tool is 'completely local' and that data does not leave the environment, but the document does not explain how that guarantee is enforced and references optional third-party scanners and AI-based verification. In a security tool, overstated data-handling assurances can mislead users into scanning sensitive code under false assumptions, creating confidentiality and compliance risk.

Lp3

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding
The skill documents commands and workflows that imply shell, filesystem, environment, and network use, but it does not declare any explicit tool scope such as permissions or allowed-tools. This creates a governance gap: an agent may invoke broader capabilities than a user expects, especially for a security-auditing skill that can read source code and potentially send data to external services.

Static analysis

No suspicious patterns detected.