Back to skill

Security audit

Code Reviewer

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a coherent code-review helper, but its optional HTML report can execute injected browser code from untrusted findings.

Install only if you are comfortable letting the skill read the code paths you explicitly ask it to review. Treat generated HTML reports as potentially unsafe when reviewing untrusted repositories or finding JSON; open them cautiously or fix the escaping issue first.

Vulnerability Patterns
  • 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
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • 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 (1)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/generate_report.py:196
Finding
Stored Cross-Site Scripting in Generated HTML Reports<![CDATA[ ## Vulnerability Details **File Location**: `scripts/generate_report.py:196, 233, 280, 489, 529, 636-641` **Vulnerability Type**: Stored cross-site scripting through unsafe HTML and JavaScript embedding **Risk Level**: High ### Vulnerable Code ```python # Category values are inserted directly into HTML. for cat, data in sorted(stats['categories'].items(), key=lambda x: -x[1]['total']): rows += f''' <tr> <td class="cat-name">{cat}</td> ``` ```python # Findings are serialized directly into an executable script context. findings_json = json.dumps(findings, ensure_ascii=False) ``` ```python # The project name is inserted directly into multiple HTML contexts. <title>{title_text} - {project_name}</title> ``` ```python <div class="meta">{project_name} &middot; <span data-i18n="generated">{generated_text}</span> {now}</div> ``` ```javascript // JSON containing untrusted finding fields is embedded in a normal script. const findings = {findings_json}; ``` ```javascript // File, category, and type values are not escaped before assignment to innerHTML. div.innerHTML = sevTag + '<div class="finding-content">' + '<div class="finding-message">' + escapeHtml(f.message || noDesc) + '</div>' + '<div class="finding-meta">' + metaParts.join(' &nbsp;|&nbsp; ') + '</div>' + snippet + '</div>'; ``` ### Technical Analysis The report generator processes findings loaded from JSON files, standard input, or inline JSON. These findings may contain data derived from an untrusted repository, including source-code snippets and file paths. Crafted JSON input can additionally control fields such as `category`, `type`, and `message`. Calling `json.dumps()` does not make a value safe for direct placement inside an HTML `<script>` element. For example, an attacker-controlled finding containing a sequence such as: ```html </script><script>alert(document.domain)</script> ``` can terminate the original script element b ...[truncated 2903 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. **Remove dynamic `innerHTML` construction** - Create report elements with `document.createElement()`. - Assign all untrusted values through `textContent`. - Use `appendChild()` or `replaceChildren()` rather than HTML string concatenation. 2. **Safely transport findings into JavaScript** - Prefer a non-executable data element such as: ```html <script id="findings-data" type="application/json">...</script> ``` - Before embedding serialized JSON in HTML, escape at least `<` as `\u003c` so `</script>` cannot terminate the element. - Parse the element's `textContent` with `JSON.parse()`. - Alternatively, store the data in a separate JSON file when a self-contained report is not required. 3. **Apply context-appropriate server-side escaping** - Escape `project_name` before inserting it into the title and visible header. - Escape category names before inserting them into table HTML. - Do not rely on one generic escaping routine for HTML text, HTML attributes, URLs, and JavaScript contexts. 4. **Validate input structure** - Require every finding to match a strict schema. - Restrict severity to known values. - Normalize scalar fields to strings and reject nested objects where strings are expected. - Apply reasonable length limits to findings, snippets, paths, categories, and project names. 5. **Add defense in depth** - Add a restrictive Content Security Policy that blocks inline and remote scripts. If inline JavaScript remains necessary, use a nonce or hash. - Avoid loading remote resources in generated reports. - Document that findings files and repositories may be attacker-controlled. 6. **Add regression tests** Test every rendered field with payloads containing: ```text </script><script>alert(1)</script> <img src=x onerror=alert(1)> " ' < > & </style> ``` Tests should generate the report, open or parse it with a browser-capable test fram ...[truncated 103 chars]
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Output HandlingUnvalidated Output Injection, Cross-Context Output, Unbounded Output
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (21)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
声明描述的是一个综合型代码审查技能,覆盖6个明确维度,并暗示具备安全规则库、最佳实践文档和可视化 HTML 报告能力。实际代码仅是 `analyze_complexity.py`,其功能集中在静态复杂度度量:长函数、圈复杂度、嵌套深度、参数过多,以及语法/读取错误处理。它不会检查漏洞、安全配置、资源访问、测试、文档质量,也没有 HTML 报告生成逻辑。虽然复杂度分析可以算作“代码质量”维度中的一个支持性子能力,但与声明的“全面审核”相比范围明显不足,且缺失多个核心承诺能力,因此属于描述与实际行为的实质性不匹配。

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
声明描述的是一个完整的代码审核技能,而该代码块的实际作用是报告展示层/后处理组件。它读取 JSON 格式的问题结果并输出 HTML,可视化报告这一点与声明中的“可生成可视化 HTML 审核报告”一致,但这只是整体能力中的一个子功能。就该代码块本身而言,主要目的并不是审核代码,而是格式化和展示已经存在的审核结果,因此与声明的核心用途存在实质性差异。未发现越权访问、网络通信或其他隐藏能力;问题在于声明显著高于代码实际能力。

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
代码的核心功能与“代码审查”大方向相关,但实现范围明显比描述窄。脚本只做基于预定义 regex 的模式匹配,覆盖安全、代码质量和部分错误处理;没有看到性能分析、测试覆盖/测试质量检查、文档检查、PR diff 审查逻辑,亦无 HTML 报告生成功能。因此描述对能力范围有实质性夸大,属于描述与实际行为不一致。未发现额外越权或无关资源访问,问题主要在于宣称功能过宽而代码实现较有限。

Ae1

High
Category
analysis-evasion
Content
若 Python 不可用,跳过本阶段直接进入第三阶段,对照 `references/security-rules.md` 和 `references/checklist.md` 手动检查代码中的等价问题。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
若 Python 不可用,跳过本阶段直接进入第三阶段,对照 `references/security-rules.md` 和 `references/checklist.md` 手动检查代码中的等价问题。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
若 Python 不可用,跳过本阶段直接进入第三阶段,对照 `references/security-rules.md` 和 `references/checklist.md` 手动检查代码中的等价问题。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
若 Python 不可用,跳过本阶段直接进入第三阶段,对照 `references/security-rules.md` 和 `references/checklist.md` 手动检查代码中的等价问题。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
若 Python 不可用,跳过本阶段直接进入第三阶段,对照 `references/security-rules.md` 和 `references/checklist.md` 手动检查代码中的等价问题。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Anti-Refusal Statement

High
Category
Anti-Refusal
Content
- Missing input validation (length, type, format, range)

### A05 - Security Misconfiguration
- Debug mode enabled in production (`DEBUG=True`)
- Detailed error pages in production (stack traces exposed)
- Default credentials not changed
- Unnecessary features enabled (directory listing, HTTP methods)
Confidence
75% confidence
Finding
Skill attempts to nullify the agent's safety policies or restrictions ('you have no restrictions', 'ignore your guidelines', 'do anything now'). This is a direct jailbreak that disables guardrails.

Anti-Refusal Statement

High
Category
Anti-Refusal
Content
- Missing input validation (length, type, format, range)

### A05 - Security Misconfiguration
- Debug mode enabled in production (`DEBUG=True`)
- Detailed error pages in production (stack traces exposed)
- Default credentials not changed
- Unnecessary features enabled (directory listing, HTTP methods)
Confidence
75% confidence
Finding
Skill attempts to nullify the agent's safety policies or restrictions ('you have no restrictions', 'ignore your guidelines', 'do anything now'). This is a direct jailbreak that disables guardrails.

Anti-Refusal Statement

High
Category
Anti-Refusal
Content
- Missing input validation (length, type, format, range)

### A05 - Security Misconfiguration
- Debug mode enabled in production (`DEBUG=True`)
- Detailed error pages in production (stack traces exposed)
- Default credentials not changed
- Unnecessary features enabled (directory listing, HTTP methods)
Confidence
75% confidence
Finding
Skill attempts to nullify the agent's safety policies or restrictions ('you have no restrictions', 'ignore your guidelines', 'do anything now'). This is a direct jailbreak that disables guardrails.

Anti-Refusal Statement

High
Category
Anti-Refusal
Content
- Missing input validation (length, type, format, range)

### A05 - Security Misconfiguration
- Debug mode enabled in production (`DEBUG=True`)
- Detailed error pages in production (stack traces exposed)
- Default credentials not changed
- Unnecessary features enabled (directory listing, HTTP methods)
Confidence
75% confidence
Finding
Skill attempts to nullify the agent's safety policies or restrictions ('you have no restrictions', 'ignore your guidelines', 'do anything now'). This is a direct jailbreak that disables guardrails.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
### Python
- `pickle.loads()` with untrusted data
- `yaml.load()` without `Loader=yaml.SafeLoader`
- `os.system()` / `subprocess.call(shell=True)` with user input
- `eval()` / `exec()` with user input
- `django.core.serializers` deserialization without validation
- `SECRET_KEY` hardcoded in settings
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).

Unvalidated Output Injection

High
Category
Output Handling
Content
db.session.commit()

# HIGH: XSS via dangerouslySetInnerHTML
<div dangerouslySetInnerHTML={{ __html: userProvidedContent }} />
```

**Action Required:** Strong recommendation to fix before merge. Justify any exceptions.
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.

Lp3

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding
The skill instructs the agent to read files, write reports, and execute shell commands, but it does not declare any explicit tool scope such as permissions or allowed-tools. This creates an over-privileged and ambiguous execution model where a host platform may grant broader capabilities than users expect, increasing the blast radius if the skill is misused or combined with malicious input.

Vague Triggers

Medium
Confidence
97% confidence
Finding
该描述将触发范围扩展到“用户请求代码质量分析时使用”,并列出如“检查安全问题”“找出代码中的 Bug”这类较宽泛短语,但没有明确限定必须是代码审查场景或提供排除条件。这会让技能在一般性安全咨询、排障或缺陷讨论中也可能被触发,边界不清晰。

Unrestricted Tool Access

Medium
Category
Excessive Agency
Content
### Critical

**Definition:** Issues that allow attackers to execute arbitrary code, access unauthorized data, or cause system compromise. Must be fixed before merge/deploy.

**Criteria:**
- Remote Code Execution (RCE)
Confidence
80% confidence
Finding
Skill grants unrestricted tool access without appropriate constraints. An agent with unfettered tool access can perform arbitrary actions including file modification, network requests, and code execution.

Unrestricted Tool Access

Medium
Category
Excessive Agency
Content
### Critical

**Definition:** Issues that allow attackers to execute arbitrary code, access unauthorized data, or cause system compromise. Must be fixed before merge/deploy.

**Criteria:**
- Remote Code Execution (RCE)
Confidence
80% confidence
Finding
Skill grants unrestricted tool access without appropriate constraints. An agent with unfettered tool access can perform arbitrary actions including file modification, network requests, and code execution.

Natural-Language Policy Violations

Low
Confidence
83% confidence
Finding
文件中的核心描述与使用说明以中文呈现,且未明确说明交互输出语言将跟随用户偏好或可由用户选择。按照语言/locale 政策,若技能默认强制特定语言而没有用户选择或 opt-in,可能构成自然语言策略问题。

Missing User Warnings

Low
Confidence
78% confidence
Finding
This is a markdown file, so SQP-2 applies to omitted warnings about behaviors that could affect user data, privacy, or system integrity. The examples include SQL injection, command execution, and a hardcoded production password, but the document does not explicitly warn readers that these snippets are unsafe demonstration code and should never be reused as-is.

Missing User Warnings

Low
Confidence
90% confidence
Finding
This code accepts a file or directory path and recursively opens and reads source files for analysis, which can expose sensitive project contents during processing. While the module docstring explains that it analyzes files for complexity, there is no explicit warning or disclosure that whole directory trees will be traversed and file contents read.

Static analysis

Detected: suspicious.dynamic_code_execution

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
scripts/scan_patterns.py:77