Back to skill

Security audit

huawei-cloud-dws-cpu-diag

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent read-only Huawei DWS CPU diagnostic helper, but it stores sensitive browser-rendered reports with incomplete HTML escaping and gives risky plaintext credential setup guidance.

Install only if you are comfortable giving the skill read access to Huawei DWS monitoring and host data. Use least-privilege IAM credentials, avoid putting AK/SK values in shell commands, protect any config files with restrictive permissions, and treat generated HTML reports as sensitive files. Do not open or share reports from untrusted clusters unless dynamic fields are safely HTML-escaped or scripts are disabled.

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

Warning
Location
SKILL.md:392
Finding

Stored HTML Injection in Browser-Rendered Diagnosis Reports

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 392–394, 423–433, and 469
Vulnerability Type: Stored HTML/script injection through insufficient output encoding
Risk Level: Medium

Vulnerable Snippets

html
<tr><td>1</td><td>{query_id}</td><td>{username}</td><td>{pct}%</td><td>{start_time_beijing}</td><td class="sql-text">{query_text}</td></tr>
<tr><td>2</td><td>{query_id}</td><td>{username}</td><td>{pct}%</td><td>{start_time_beijing}</td><td class="sql-text">{query_text}</td></tr>
<tr><td>3</td><td>{query_id}</td><td>{username}</td><td>{pct}%</td><td>{start_time_beijing}</td><td class="sql-text">{query_text}</td></tr>

The diagnosis summary also embeds the username without an encoding requirement:

html
<div class="loc-row"><span class="loc-key">用户名</span><span class="loc-val">{username}</span></div>

The general output rule only mandates escaping SQL text:

text
Output is a complete HTML document that can be rendered directly in a browser; `<` `>` `&` in SQL text must be escaped as `&lt;` `&gt;` `&amp;`.

Technical Analysis

The Skill retrieves database usernames and related diagnostic fields from cpu_io_diagnose_detail, places those values into an HTML report, saves the report to the workspace, and expects it to be rendered in a browser. The report template inserts {username} directly into HTML element content.

Although the instructions explicitly require escaping <, >, and & in SQL text, they do not impose equivalent contextual HTML encoding on usernames. A database principal capable of selecting a specially crafted quoted username can therefore cause markup to enter the monitoring results and subsequently the generated report.

For example, a username containing an HTML element with an event handler would be interpreted as markup rather than displayed as text if inserted without encoding. This is an exploitable output-encoding flaw rather than evidence that the Skill author deliberately intended t ...[truncated 1753 chars]

Remediation
View remediation

Remediation Suggestions

  1. Apply contextual HTML encoding to every dynamic value before inserting it into the report, including:

    • Database and operating-system usernames
    • Cluster and node names
    • Resource, query, and project identifiers
    • SQL text and summaries
    • Process and command names
    • Tool-returned error messages and metric values
  2. Use a template engine with automatic HTML escaping rather than direct string substitution. Permit raw HTML only for fixed markup generated internally by trusted report logic.

  3. Encode at least &, <, >, ", and ' for values inserted into HTML text or attributes. Use context-specific encoders for URLs, CSS, or attributes if dynamic values are ever introduced into those contexts.

  4. Keep diagnosis_summary structured internally as data rather than preformatted HTML. Render its fields through the same escaping template layer.

  5. Add regression tests using values such as:

text
<img src=x onerror=alert(1)>
"><svg onload=alert(1)>
<script>alert(1)</script>

The resulting report must display these values as literal text and must not create executable DOM elements.

  1. Consider adding a restrictive Content Security Policy to the generated report as defense in depth, for example by disallowing scripts and limiting network destinations. This does not replace correct output encoding.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Memory PoisoningPersistent Context Injection, Context Window Stuffing, Memory Manipulation
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (9)

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
80% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

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

md
- Valid Huawei Cloud credentials (AK/SK mode or IAM Token)
- **Security Rules**:
  - Never expose AK/SK values in conversations or commands
  - Never ask users to input AK/SK directly in conversation
  - Only use `hcloud configure list` to check credential status

### 4. IAM Permission Requirements

Context Window Stuffing

Medium
Category
Memory Poisoning
Confidence
80% confidence
Finding

Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Content

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

md
### Step 4: Query CPU Highest Node Diagnosis Details

Call metric query with metric_name="cpu_io_diagnose_detail". Does not support host_id filtering; query full cluster then filter by nodes_to_analyze from Step 1 output. **MCP mode must use limit=200 paginated query** (this metric has the largest data volume; single page of 800 will exceed token limit), until returned count < 200, merge all paginated data before filtering.

**Parsing**: Extract active queries, users, duration, process information. ctime is collection time, not SQL start time; when duration_ms exists, SQL start time = ctime - duration_ms. Only count users with state=active. inst_name contains "cn" → CN instance; contains "dn" → DN instance.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill explicitly instructs the agent to write a rendered HTML report into the workspace, which exceeds the declared output-only behavior and introduces an unnecessary filesystem side effect. Any file write can create persistence, expose sensitive diagnostic contents to other workspace consumers, or be abused in broader agent chains where workspace artifacts are later trusted or exfiltrated.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

Persisting a timestamped HTML file is not necessary to perform CPU diagnosis and broadens the skill's privileges beyond its stated purpose. The generated report may contain cluster identifiers, hostnames, SQL text, usernames, and timing data, so storing it on disk increases the risk of unintended disclosure or later misuse by other tools that scan the workspace.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The report template hard-codes lang="zh-CN", and nearby instructions require all report times to be rendered in Beijing time. This imposes a specific language/locale on all outputs without offering a user choice or clearly limiting the skill to a China-only compliance context.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
80% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

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

md
## Notes

- **Security**: Never expose AK/SK values in conversations or commands; never ask users to input AK/SK directly in conversation
- **Time Protocol**: from_ts/to_ts must use millisecond timestamps; report displays Beijing time; when converting Beijing time to timestamp, must append +08:00 timezone suffix; do not mentally calculate timestamp values; do not convert existing millisecond timestamps to time strings and then back
- **Output Constraints**: Strictly output the diagnosis report following the Output Format section template; do not modify template structure, do not omit any part, do not add remediation suggestions, do not output SQL optimization statements, do not use emoji, do not use custom format tags
- **Data Authenticity**: All diagnosis conclusions must come from actual tool return results; when tool returns empty or call fails, mark as "无法获取"; fabricating values is prohibited

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The guide instructs users to place AK/SK credentials in plaintext in a YAML file and on the CLI before encryption occurs, but it does not prominently warn about exposure risks such as shell history, process listings, file permissions, backups, or source control leakage. In a security-sensitive ops tool that accesses cloud monitoring and host data, this omission can realistically lead to credential compromise.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
85% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

Scanner excerpt · references/dws-mcp-installation-guide.md (reported line 99)May include surrounding context.

Other Commands

bash
# Manually trigger encryption (auto-executed on MCP Server startup as well)
python -m dws_autopilot_mcp.config_cli encrypt

# Show config status (secrets are masked as ******)

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

The file begins with 'English | [中文]' and the entire guide is written in English by default, which can be interpreted as imposing a language choice without explicit user opt-in. Although a Chinese alternative is linked, the document itself does not present language selection as a user choice within the content.

Content

No source excerpt is available for this finding.