Back to skill

Security audit

Alibaba Cloud Backup BDRC

Security checks for vulnerabilities and agentic risk

Overview

This Alibaba Cloud BDRC skill is mostly coherent, but it deserves review because it enables high-impact backup configuration changes and includes a helper script with an output-path validation flaw.

Review this skill before installing in any production Alibaba Cloud account. Use least-privilege BDRC credentials, require explicit human approval for Create/Update/Modify/Set operations, record rollback steps, and avoid untrusted product-code/version overrides until the helper script validates filenames and constrains writes to output/aliyun-bdrc-backup/.

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
scripts/list_openapi_meta_apis.py:32
Finding
Output Path Traversal Through Unvalidated Product Code and Version Arguments## Vulnerability Details **File Location**: `scripts/list_openapi_meta_apis.py`, lines 32–33 and 69–78 **Vulnerability Type**: Path traversal and insufficient output-path validation **Risk Level**: Medium ### Vulnerable Code ```python parser.add_argument("--product-code", default=DEFAULT_PRODUCT_CODE) parser.add_argument("--version", default=DEFAULT_VERSION) ``` ```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" json_file.write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8") md_lines = [ f"# {args.product_code} {args.version} API List", "", f"- Source: {url}", f"- API count: {len(api_names)}", "", ] md_lines.extend([f"- `{name}`" for name in api_names]) md_file.write_text("\n".join(md_lines) + "\n", encoding="utf-8") ``` ### Technical Analysis The `--product-code` and `--version` command-line arguments are accepted without format validation and are interpolated directly into filesystem paths. `pathlib.Path` does not automatically constrain a joined path to its intended parent directory. Values containing path separators and traversal components such as `..` can therefore cause the generated artifact path to resolve outside `output/aliyun-bdrc-backup/`. The base output directory is created, but parent directories introduced through malicious argument values are not created. Exploitation consequently requires the traversed destination directories to exist. In addition, the network request must return valid JSON before either file write is reached. These constraints reduce exploitability but do not enforce the documented output boundary. The fixed filename suffixes restrict the exact names an attacker can target, but the script may still create or overwrite matching files elsewhere under the executing user's writable filesystem. ### Attack Path 1. ...[truncated 1878 chars]
Remediation
## Remediation Suggestions 1. Apply strict allowlist validation before using either argument: ```python import re PRODUCT_RE = re.compile(r"^[A-Za-z0-9_-]+$") VERSION_RE = re.compile(r"^\d{4}-\d{2}-\d{2}$") if not PRODUCT_RE.fullmatch(args.product_code): parser.error("Invalid product code") if not VERSION_RE.fullmatch(args.version): parser.error("Invalid API version") ``` 2. Resolve every output path and verify that it remains below the resolved output directory: ```python output_dir = pathlib.Path(args.output_dir).resolve() output_dir.mkdir(parents=True, exist_ok=True) json_file = ( output_dir / f"{args.product_code}_{args.version}_api_docs.json" ).resolve() md_file = ( output_dir / f"{args.product_code}_{args.version}_api_list.md" ).resolve() for candidate in (json_file, md_file): if not candidate.is_relative_to(output_dir): raise ValueError("Generated output path escapes the output directory") ``` 3. For compatibility with Python versions lacking `Path.is_relative_to()`, compare paths using `relative_to()` and reject `ValueError`. 4. Reject path separators, `.` components, `..` components, absolute paths, control characters, and platform-specific separators in all values used to construct filenames. 5. If overwriting existing artifacts is unnecessary, use exclusive file creation mode to reduce overwrite risk. 6. Add regression tests covering Unix and Windows path separators, absolute paths, nested traversal sequences, encoded traversal strings, and symlinks within the output directory.
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 (9)

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
96% confidence
Finding
The stated purpose is active BDRC management, including configuration changes and troubleshooting, but the documented quickstart centers on OpenAPI metadata discovery and artifact generation instead of actual resource operations. This mismatch can mislead operators and orchestration logic into invoking the skill in inappropriate contexts, causing unnecessary external calls, credential exposure to discovery tooling, or unsafe assumptions about what the skill will do.

Lp3

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding
The skill advertises executable workflows that rely on environment credentials, network access, and local file writes, but it does not declare any explicit tool scope or permission boundaries. In an agent environment, this increases the chance of over-privileged execution, unintended credential use, and unreviewed external calls or artifact creation.

Vague Triggers

Medium
Confidence
93% confidence
Finding
The activation condition is broad enough to trigger for many backup and disaster-recovery requests without clear limits on when the skill should be used, whether it is discovery-only, or when human confirmation is required. In a high-impact cloud backup/DR context, ambiguous routing can lead to accidental execution against production resources or unnecessary handling of sensitive cloud credentials.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill explicitly discusses Create, Update, Modify, and Set operations for backup and disaster-recovery resources but does not include strong warnings, confirmation gates, or rollback considerations. In this context, mutations can disrupt backup coverage, alter retention or recovery settings, and impact recoverability of protected systems, making the omission materially dangerous.

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.

Static analysis

No suspicious patterns detected.