Back to skill

Security audit

huawei-cloud-sac-dify

Security checks for vulnerabilities and agentic risk

Overview

This deployment skill is mostly coherent, but it needs review because it can create/delete paid cloud resources, stores cloud credentials locally, and has an unsafe Playwright npx fallback.

Install only if you intend to let the agent work with Huawei Cloud infrastructure and possible cloud charges. Use a limited IAM user, inspect `terraform plan` carefully, and require explicit confirmation before apply or destroy. Prefer environment variables or a secret manager over plaintext tfvars where possible, remove any local credential file promptly, and install a vetted Playwright CLI directly rather than relying on the npx fallback.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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)

T08 · Insecure Dependencies

Warning
Location
scripts/playwright_utils.py:20
Finding
Unintended npm Package Execution Through an Incorrect Playwright CLI Fallback## Vulnerability Details **File Location**: `scripts/playwright_utils.py`, lines 20–27 **Vulnerability Type**: Dependency substitution caused by inconsistent package names **Risk Level**: Medium **Vulnerable code:** ```python def build_pw_command() -> list[str]: pw = resolve_command("playwright-cli") if pw: return [pw] npx = resolve_command("npx") if npx: return [npx, "playwright-cli"] raise RuntimeError( "playwright-cli is not installed. Install with: npm install -g @playwright/cli@latest" ) ``` ### Technical Analysis The documented dependency is the scoped npm package `@playwright/cli`, but the automatic fallback executes `npx playwright-cli`, referring to a different, unscoped package name. This path is reachable when `extract_sac_deploy_info.py` calls `build_pw_command()` and no `playwright-cli` executable is present in `PATH`, while `npx` is available. Depending on normal `npx` behavior and the local npm configuration, the command may retrieve and execute the mismatched package. The fallback therefore crosses a package trust boundary: code from a package other than the dependency identified by the Skill is allowed to execute with the invoking user's privileges. The project contains no evidence that this mismatch is intentional or malicious. ### Attack Path 1. A user invokes `scripts/extract_sac_deploy_info.py` as directed by the Skill. 2. The expected `playwright-cli` executable is absent from `PATH`. 3. `build_pw_command()` detects an available `npx` executable. 4. The helper constructs the command `npx playwright-cli` rather than invoking the documented `@playwright/cli` package. 5. `run_pw()` executes that command using `subprocess.run`. 6. If the unscoped package is not already installed, `npx` may retrieve it from the configured npm registry and execute its entry point. 7. Code supplied by that unintended dependency runs under the account exec ...[truncated 394 chars]
Remediation
## Remediation Suggestions - Replace the unscoped fallback with the exact intended package: ```python return [npx, "--yes", "@playwright/cli@<reviewed-version>"] ``` - Pin a reviewed version rather than relying on a mutable latest release. - Prefer requiring an explicitly installed and verified `playwright-cli` executable instead of downloading a package during Skill execution. - Keep the package name consistent across the installation guide, runtime fallback, and error messages. - If automatic installation is retained, use a trusted registry configuration and verify the resolved package and version before execution.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (14)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The declared description says the skill deploys Dify on Huawei Cloud with ECS via Terraform/SAC templates. However, the supplied code only gathers deployment-related information from a SAC detail page: it launches a browser session, visits a provided URL, extracts title/price/link data, scores candidate Terraform/template links, and writes JSON output. There is no Terraform execution, no Huawei Cloud resource creation, no Dify deployment logic, and no SAC template application. While the extracted information could support a later deployment workflow, this code chunk’s primary purpose is metadata extraction/scraping, which is materially different from the declared deployment capability.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared purpose says this skill should deploy Dify on Huawei Cloud using Terraform. However, the actual code only parses Terraform files to list variable defaults from a local directory. While this may be a supporting utility within a Terraform project, the provided code chunk itself does not carry out the advertised primary function of deploying Dify or managing Huawei Cloud infrastructure. Its actual purpose is materially different: Terraform variable introspection/reporting.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The declared description says the skill deploys Dify on Huawei Cloud via Terraform/SAC templates. However, the supplied code chunk only implements shared Playwright CLI utilities: resolving commands, invoking playwright-cli or npx, running code snippets, handling subprocess failures, cleaning terminal output, and parsing JSON from output text. These are generic browser automation/CLI helper capabilities and are materially different from cloud infrastructure deployment. There is no evidence in this chunk of Terraform template generation, Huawei Cloud resource provisioning, ECS interaction, or Dify-specific deployment steps. Therefore the code does not accurately represent the declared purpose.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
The declared purpose says this skill deploys Dify on Huawei Cloud via Terraform/SAC. However, the supplied code contains no deployment, no Huawei Cloud API usage, no Terraform execution, and no template application logic. Its actual function is browser automation for information extraction: closing consent dialogs, scrolling, parsing visible text for pricing/cost strings, collecting deployment-related links, and optionally opening a cost documentation page to collect additional pricing text. That is materially different from deploying Dify. While extracting deploy links or cost information could support a larger deployment workflow, this code chunk’s primary behavior is webpage scraping and metadata extraction, not infrastructure deployment.

Lp3

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding
The skill describes use of environment variables, local file creation/editing, shell commands, curl, and Terraform, but it does not declare any explicit tool scope or allowed-tools boundary. That weakens least-privilege controls and can let an agent invoke broader capabilities than users or reviewers expect, especially since the workflow handles credentials and infrastructure changes.

Vague Triggers

Medium
Confidence
95% confidence
Finding
The trigger phrases include broad terms like 'Dify development', 'Agentic workflow', and 'build AI App', which can cause the skill to activate in contexts far beyond the narrow Huawei Cloud Terraform deployment use case. Over-broad activation increases the chance of unexpected shell execution, file handling, or infrastructure-related guidance being used in irrelevant or unsafe contexts.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
### Security

- 🚫 Never expose AK/SK in conversation or output
- 🚫 Never ask user to type AK/SK in chat
- ✅ Prefer IAM users over primary account
- ✅ Modification ops (`apply`, `destroy`) require explicit user confirmation
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.

External Transmission

Medium
Category
Data Exfiltration
Content
### Install — Linux / macOS

```bash
curl -fsSL -o /tmp/terraform.zip "<URL_from_table_above>"
unzip -o /tmp/terraform.zip -d /usr/local/bin/
```
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
This markdown file lists `terraform destroy` and describes deletion of managed resources, but it does not include an explicit warning about the destructive impact on infrastructure or potential data loss. For markdown files, safety-impacting behaviors should be accompanied by clear user warnings when they can affect system integrity or user data.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The verification steps explicitly require writing cloud credentials (`access_key`, `secret_key`) into `terraform.auto.tfvars.json`, which is a plaintext file commonly consumed automatically by Terraform. Even though the document says the file should not be committed to git, it provides no strong warning about secret exposure in local files, shell history, backups, logs, or multi-user environments, and it normalizes a risky secret-handling pattern for a deployment skill.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
allow_failure: bool = False,
) -> subprocess.CompletedProcess:
    full_cmd = [*base_cmd, f"-s={session}", *args]
    proc = subprocess.run(
        full_cmd,
        capture_output=True,
        text=True,
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Natural-Language Policy Violations

Medium
Confidence
94% confidence
Finding
The script only attempts to dismiss dialogs using Chinese button labels such as '知道了', '关闭', and '同意'. This embeds a locale-specific assumption in the skill behavior and provides no indication that language choice is configurable or limited to a justified Chinese-only context.

Missing User Warnings

Low
Confidence
83% confidence
Finding
The helper invokes an external executable via subprocess.run, which is a safety-relevant operation for code files under the audit criteria. In this file there is no confirmation prompt, user-facing log/print, or explanatory comment/docstring near the execution path disclosing that commands will be run; the module docstring is too generic to serve as a warning.

Missing User Warnings

Low
Confidence
79% confidence
Finding
This function writes the provided script to a temporary .js file and later deletes it, which constitutes file write/delete behavior covered by the missing-warning rule for code files. The code has no user-facing notice and only an implementation comment about backward compatibility, not a disclosure that user-provided script content is persisted to disk temporarily.

Static analysis

No suspicious patterns detected.