Back to skill

Security audit

Alibaba Cloud Security CloudFW

Security checks for vulnerabilities and agentic risk

Overview

This is a disclosed Alibaba Cloud Firewall management skill with expected credential, API, and local-output behavior, but users should treat mutating firewall changes carefully.

Install only where Alibaba Cloud credentials are already intended for Cloud Firewall administration. Prefer least-privilege credentials, review any proposed Create/Update/Modify/Set action before execution, and keep generated outputs in the documented output directory.

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

Note
Location
scripts/list_openapi_meta_apis.py:29
Finding
Unsanitized API Identifiers Can Escape the Intended Output Directory<![CDATA[ ## Vulnerability Details **File Location**: `scripts/list_openapi_meta_apis.py`, lines 29–31 and 59–60 **Vulnerability Type**: Path traversal through user-controlled filename components **Risk Level**: Low ### Vulnerable Code ```python parser.add_argument("--product-code", default=DEFAULT_PRODUCT_CODE) parser.add_argument("--version", default=DEFAULT_VERSION) parser.add_argument("--output-dir", default=str(OUTPUT_DIR)) ``` ```python json_file = output_dir / f"{args.product_code}_{args.version}_api_docs.json" md_file = output_dir / f"{args.product_code}_{args.version}_api_list.md" ``` ### Technical Analysis The `--product-code` and `--version` arguments are incorporated directly into output filenames without validation. Python's `pathlib` does not automatically prevent filename components containing path separators or `..` traversal components from resolving outside the intended output directory. Although the default values are safe, a caller can supply crafted values containing traversal sequences. The script subsequently writes the downloaded JSON metadata and generated Markdown content to the resulting paths. Exploitation is constrained because the same argument values are also inserted into the Alibaba Cloud metadata URL, and the network request must return valid JSON before the write operations occur. Nevertheless, the code does not enforce the documented boundary of `output/aliyun-cloudfw-manage/`, so a successful response for crafted identifiers could result in an out-of-directory write. The separately flagged credential behavior does not constitute a confirmed vulnerability. `SKILL.md` documents standard Alibaba Cloud credential sources, but this script does not read those credentials or include them in its HTTPS request. It contacts only the documented `api.aliyun.com` metadata endpoint. ### Attack Path 1. An attacker or untrusted workflow controls the arguments passed to the script. 2. The attacker supplies a `--product-code` or `- ...[truncated 1192 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Validate `--product-code` and `--version` against a strict allowlist before using them in URLs or filenames. For example, permit only letters, digits, periods, underscores, and hyphens: ```python import re SAFE_IDENTIFIER = re.compile(r"^[A-Za-z0-9._-]+$") for label, value in ( ("product-code", args.product_code), ("version", args.version), ): if not SAFE_IDENTIFIER.fullmatch(value) or value in {".", ".."}: parser.error(f"Invalid {label}: only safe identifier characters are allowed") ``` 2. Resolve each destination and verify that it remains beneath the resolved output directory: ```python output_root = output_dir.resolve() json_file = (output_root / f"{args.product_code}_{args.version}_api_docs.json").resolve() md_file = (output_root / f"{args.product_code}_{args.version}_api_list.md").resolve() for destination in (json_file, md_file): if not destination.is_relative_to(output_root): raise ValueError(f"Output path escapes output directory: {destination}") ``` 3. Apply the same validation before constructing the URL, or URL-encode each path segment with a strict safe-character policy. 4. Consider refusing absolute output paths unless explicitly required. If custom output directories are supported intentionally, document that they determine the write boundary. 5. Add regression tests covering `../`, absolute paths, embedded separators, encoded separators, empty identifiers, and valid Cloud Firewall product/version values. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (10)

Tainted flow: 'timeout' from os.getenv (line 34, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Content
def fetch_json(url: str, timeout: int) -> dict:
    req = urllib.request.Request(url, headers={"User-Agent": "codex-skill"})
    with urllib.request.urlopen(req, timeout=timeout) as resp:
        return json.loads(resp.read().decode("utf-8"))
Confidence
90% confidence
Finding
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
The declared purpose describes an operational management skill for Alibaba Cloud Cloud Firewall using OpenAPI/SDK—implying actions like resource operations, policy changes, status checks, or troubleshooting API workflows. The supplied code does not perform Cloud Firewall management or invoke Cloud Firewall operational APIs. Instead, it downloads API documentation metadata from api.aliyun.com for a product/version, parses the API list, and saves JSON/Markdown reference files locally. While this is related to Cloudfw in a documentation/discovery sense, its primary purpose is metadata retrieval and documentation generation, which is materially different from the declared management-oriented behavior.

Lp3

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding
The skill uses sensitive capabilities including environment-variable credential access, filesystem writes, and network/API interaction, but declares no explicit tool scope or permission boundaries. In an agent setting, this weakens governance and can allow broader-than-expected execution with cloud credentials and outbound requests, increasing the chance of accidental or unauthorized actions.

Vague Triggers

Medium
Confidence
92% confidence
Finding
The trigger description is broad enough to activate on many general firewall-related requests without clear boundaries, which can cause the agent to invoke a cloud-management skill inappropriately. In this context, over-triggering is risky because the skill is positioned to use credentials and potentially perform firewall-affecting operations, raising the chance of unintended cloud actions.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill explicitly covers mutating firewall operations such as Create, Update, Modify, and Set without an embedded safety warning or mandatory confirmation step. Because firewall changes can immediately alter network exposure, block production traffic, or reduce protections, executing such actions without a clear warning and approval gate is operationally and security-sensitive.

External Transmission

Medium
Category
Data Exfiltration
Content
output_dir.mkdir(parents=True, exist_ok=True)

    url = (
        f"https://api.aliyun.com/meta/v1/products/{args.product_code}"
        f"/versions/{args.version}/api-docs.json"
    )
    payload = fetch_json(url, timeout)
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
output_dir.mkdir(parents=True, exist_ok=True)

    url = (
        f"https://api.aliyun.com/meta/v1/products/{args.product_code}"
        f"/versions/{args.version}/api-docs.json"
    )
    payload = fetch_json(url, timeout)
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
output_dir.mkdir(parents=True, exist_ok=True)

    url = (
        f"https://api.aliyun.com/meta/v1/products/{args.product_code}"
        f"/versions/{args.version}/api-docs.json"
    )
    payload = fetch_json(url, timeout)
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
output_dir.mkdir(parents=True, exist_ok=True)

    url = (
        f"https://api.aliyun.com/meta/v1/products/{args.product_code}"
        f"/versions/{args.version}/api-docs.json"
    )
    payload = fetch_json(url, timeout)
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

Low
Confidence
83% confidence
Finding
This Python code performs an HTTP request to an external service and writes the fetched payload and derived markdown to disk. While the module docstring mentions saving to output/, there is no runtime confirmation or explicit user-facing warning about the outbound network access and resulting file creation.

Static analysis

No suspicious patterns detected.