Back to skill

Security audit

arch-diagram

Security checks for vulnerabilities and agentic risk

Overview

This skill appears intended to generate local architecture diagrams, but it has review-worthy weaknesses that can read files outside the target repo through symlinks and generate HTML that can run injected scripts.

Install only if you trust the repositories you will scan and are comfortable sending source contents into the agent workflow. Avoid running it on repos that may contain symlinks, secrets, or untrusted code comments, and treat generated HTML reports as active web pages rather than inert documents.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
Findings (4)

T01 · Skill Instruction Hijacking

Error
Location
references/prompts.md:8
Finding

Untrusted Repository Content Can Hijack Model Instructions

Content
View full analysis
` 的形式 - 让 Claude(自己)生成一个 JSON 对象 `{"文件路径": "摘要"}` - 合并所有批次的摘要,得到完整的 `code_summary` 字典 ``` `references/prompts.md:8-31`: ```text 你是一名资深软件工程师。请阅读以下代码文件列表,为每个文件生成一句话摘要(不超过30字),概括其业务功能。 只输出一个 JSON 对象,格式为 {"文件路径": "一句话摘要", ...},不要任何多余内容。 注意: - 摘要要体现业务语义(如"处理用户登录逻辑"),而非技术细节(如"定义了3个类") - 最多提及关键类名或方法名 - 不要超过30字 $FILES ``` The `$FILES` value is populated as follows: ```text === 文件: path/to/file1.py === <文件内容> === 文件: path/to/file2.java === <文件内容> ``` ### Technical Analysis The Skill directly inserts attacker-controlled source-file contents into an Agent prompt. The prompt does not establish that repository content is untrusted data and does not instruct the model to ignore commands, role changes, output overrides, or tool-use requests found inside source files. Comments, strings, documentation blocks, or other text in a scanned repository can therefore contain instructions that compete with the Stage 1 prompt. If followed, those instructions can alter the generated summary JSON. The resulting summaries are then trusted by Stage 2 and Stage 3, allowing the injected instructions to influence architecture nodes, file associations, relationship data, and Mermaid content. The output requirement to return JSON is not a security boundary. An attacker can ask the model to return syntactically valid but misleading or payload-bearing JSON. ### Attack Path 1. An attacker places instruction-like content inside a supported source file, such as a `.py`, `.js`, or `.ts` file. 2. `scan_repo.py` reads that file and returns its complete contents. 3. The Skill inserts ...[truncated 1101 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/scan_repo.py:96
Finding

Repository Symlinks Can Expose Files Outside the Repository Root

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/build_html.py:62
Finding

Unsafe HTML Template Substitution Enables Script Injection

Content
View full analysis
", repo_name) template = template.replace( "", json.dumps(mindmap_str, ensure_ascii=False) ) template = template.replace( "", json.dumps(flowchart_data, ensure_ascii=False) ) template = template.replace( "", json.dumps(edges_data, ensure_ascii=False) ) template = template.replace( "", json.dumps(meta, ensure_ascii=False) ) ``` `assets/arch_diagram_static.html:606-622`: ```html ``` ### Technical Analysis `repo_name` is inserted directly into both HTML and an executable JavaScript string without context-sensitive escaping. A quote in the value can terminate the JavaScript string and introduce executable syntax. The remaining values are processed with `json.dumps()`, which protects JSON string delimiters but does not make a value safe for direct placement inside an HTML `
Remediation
View remediation
` elements and read it through `textContent`. 3. Before embedding JSON in HTML, escape at least `<`, `>`, `&`, and the Unicode line-separator characters. For example, encode `<` as `\u003c`. 4. Serialize `repo_name` using a context-aware JavaScript serializer rather than placing it inside literal quotation marks. 5. HTML-escape the repository name when inserting it into the `` element. 6. Prefer a well-maintained template engine with automatic context-aware escaping. 7. Add a restrictive Content Security Policy. Remove inline scripts or authorize reviewed scripts with hashes or nonces. 8. Validate all generated fields against strict schemas and reasonable length limits. 9. Test payloads containing: - Quotes and backslashes. - `</script>`. - HTML tags. - Unicode line separators. - Strings propagated from mindmap, Mermaid, metadata, and edge fields. ]]>

T08 · Insecure Dependencies

Warning
Location
assets/arch_diagram_static.html:625
Finding

Generated Reports Execute an Integrity-Unprotected Third-Party CDN Script

Content
View full analysis
``` ### Technical Analysis Every generated report loads and executes Mermaid JavaScript from a third-party CDN at runtime. Although the URL specifies a version, the script element does not provide a Subresource Integrity hash. The browser therefore has no cryptographic mechanism to verify that the received script is the exact reviewed Mermaid artifact. The page also lacks a restrictive Content Security Policy in the reviewed template. A compromised CDN, malicious upstream replacement, DNS or network redirection under a weakened trust environment, or CDN account compromise could cause arbitrary JavaScript to execute when a report is opened. This behavior also conflicts with the documented expectation that the generated file is an independent static HTML page, because rendering requires an external network dependency. ### Attack Path 1. The user generates an architecture report. 2. The user opens the report while connected to a network. 3. The browser requests `mermaid.min.js` from the configured third-party CDN. 4. The CDN resource or delivery path supplies modified JavaScript. 5. Because no integrity hash is present, the browser accepts and executes the modified resource. 6. The malicious dependency runs with the same page privileges as the report's own JavaScript. ### Impact Assessment A compromised dependency can execute arbitrary browser-side JavaScript in every generated report that loads it. This can allow: - Manipulation of report contents. - Collection of report metadata and architecture information. - Outbound exfiltration requests. - Phishing or malicious UI injection. - Exploitation of privileges associated with a trusted hosting origin if the report is se ...[truncated 236 chars]
Remediation
View remediation
``` 4. Use a restrictive Content Security Policy that permits scripts only from explicitly approved sources and preferably disallows inline scripts. 5. Establish a dependency-update process that verifies release provenance, hashes, security advisories, and license information. 6. Add an offline test confirming that the generated report works without network access. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (19)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

声明描述的是一个端到端的仓库架构可视化技能:扫描仓库、分析代码、产出图数据并生成 HTML。实际代码只是后处理/渲染步骤:读取现成的 mindmap 文本和若干 JSON 文件,替换 HTML 模板占位符,输出静态网页。从权限和资源访问看,它只访问指定输入文件和模板文件,没有自动扫描当前目录的逻辑,也没有仓库解析、架构理解或图生成逻辑。因此该代码片段与声明的主要能力明显不一致;它最多覆盖了“最终输出 HTML 文件”的最后一步。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

声明描述的是一个端到端的“代码仓架构可视化生成器”,最终产物应是独立静态 HTML 页面,包含架构图/思维导图/模块流程图。而实际代码只是前置数据收集脚本:扫描代码文件、读取内容、计算 LOC 和技术栈统计,并输出 JSON 供后续处理。它没有任何 HTML 生成、浏览器页面构建、图表/流程图渲染、架构推理或可视化逻辑。虽然“扫描代码仓”与声明中的前置步骤部分相关,但该代码块的实际主要功能与声明的主要交付物明显不一致,因此应判定为描述与行为不匹配。

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 30)May include surrounding context.

md
- `assets/arch_diagram_static.html` — HTML 模板

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · assets/arch_diagram_static.html (reported line 6)May include surrounding context.

html
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>架构可视化图 - <!--REPO_NAME--></title>
    <style>
        * {
            margin: 0;

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
86% confidence
Finding

The skill instructs the agent to read from the repository, write cache/output files, and invoke local scripts, but it does not declare any explicit tool scope or permissions boundary. In an agent environment, this increases the chance of over-broad file access or unintended writes because users and policy layers cannot clearly constrain what the skill is allowed to touch.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill description does not clearly warn that it will scan the entire current repository and read source contents. In a code-assistant context, this matters because repositories often contain secrets, proprietary code, or unrelated sensitive files, and a user may trigger broad ingestion without understanding the scope.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The natural-language description and operating instructions are written entirely in Chinese and do not indicate that language is configurable or intentionally limited to a Chinese-only audience. Under the policy, forcing a specific language without user opt-in is a locale/language constraint that should be documented or made optional.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The root HTML tag sets lang="zh-CN", and the user-facing UI text throughout the page is also hard-coded in Chinese. For a general-purpose architecture visualization page, this imposes a specific language/locale without any opt-in or justification, which matches the natural-language locale policy violation criteria.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The static HTML unconditionally loads Mermaid from a third-party CDN, which introduces an external network trust dependency into a tool advertised as a standalone local visualization page. If the CDN is unavailable, blocked, or serves compromised content, the generated page can fail open or execute attacker-controlled JavaScript in the browser context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The Stage 2 prompt explicitly instructs the model to '使用中文', which imposes a specific language choice on all users. This is a natural-language policy concern because the file does not provide user opt-in, alternatives, or a documented justification for requiring Chinese output.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The Stage 2a prompt again requires output in Chinese via '使用中文' with no opt-in or fallback language. Requiring a fixed language across users can violate language/locale policy when not explicitly justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The Stage 2b prompt mandates Chinese output using '使用中文' while giving no user choice and no rationale for the locale constraint. This is a repeated policy issue in natural-language instructions.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The Stage 3 prompt specifies '使用简体中文', which is an explicit locale requirement. Because the file does not offer a language choice or explain why Simplified Chinese is required, this creates a language/locale policy violation.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The script serializes and prints the full contents of every discovered code file to stdout, which can expose secrets, proprietary source, or unrelated sensitive material present in the scanned tree. In the context of a skill that claims to generate an architecture diagram, exporting raw source is an over-collection/data-exposure risk because downstream components receive far more data than is necessary for the stated purpose.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest describes a root-only, current-directory-based workflow, but this script requires an explicit repo_path argument and will scan whatever directory the caller supplies. That is a semantic mismatch in operating scope and invocation model, even though the underlying task is still repository scanning.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The skill writes cache, temporary, and final output files, including predictable paths under cache/, output/, and /tmp, but the description does not prominently disclose this. Undocumented writes can expose summarized code content, metadata, or generated diagrams to other local users or later processes, especially on shared systems.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

This code file contains natural-language strings that require Chinese comprehension for usage, parameters, and output interpretation. Under the policy, forcing a specific language without opt-in is a locale/language policy issue when no alternative language or justification is provided.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The module docstring, usage text, and output descriptions are entirely in Chinese, and the CLI argument descriptions later in the file also assume Chinese-language users. Under the language/locale policy rule, this is a natural-language constraint without any opt-in, alternative locale, or justification that the skill is region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

Natural-language strings in the module docstring specify behavior and usage entirely in Chinese, including the stated output contract, and the CLI descriptions later continue this pattern. For a general-purpose repository scanning script, this imposes a specific language/locale without user opt-in or a documented justification, which matches the policy-violation category.

Content

No source excerpt is available for this finding.