Back to skill

Security audit

Alibabacloud Migration Mas Cloud Migration Survey

Security checks for vulnerabilities and agentic risk

Overview

The skill is mainly a migration-report generator, but it can automatically create or overwrite files at user-supplied paths and may save sensitive data before only warning about it.

Review this skill before installing. Use it only in a sandboxed workspace, avoid absolute paths for missing files, do not feed it live credentials or secrets, and manually inspect generated reports before sharing them. The main risk is unintended local file creation or overwrite and accidental persistence of sensitive customer details in the output document.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (2)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/generate_report.py:713
Finding

Sensitive information is persisted in generated reports before warning-only detection

Content
View full analysis

Vulnerability Details

File Location: scripts/generate_report.py, lines 713-721 and 784-800
Vulnerability Type: Sensitive-data exposure caused by post-write, non-blocking validation
Risk Level: Medium

Vulnerable Code

python
try:
    doc.save(output_path)
    logger.info(f"报告已保存: {output_path}")
except PermissionError:
    raise PermissionError(f"无法写入文件(权限不足或文件被占用): {output_path}")
except OSError as e:
    raise OSError(f"文件保存失败: {output_path} ({e})")

return output_path

The quality check only detects sensitive information after the document has been saved:

python
# 敏感信息检测:代码级防护兜底(IP、AccessKey、密码、密钥等)
sensitive_findings = detect_sensitive_data(full_text)
if sensitive_findings:
    for finding in sensitive_findings:
        results['warnings'].append(f"[敏感信息检测] 报告中发现 {finding},请确认是否为公开信息,必要时进行脱敏处理")
    results['sensitive_data_count'] = len(sensitive_findings)

logger.info(f"质检结果: {'通过' if results['passed'] else '未通过'}")

The command-line workflow also treats sensitive-data findings as informational rather than as a quality-check failure:

python
results = quality_check(output_path)
if not results['passed']:
    print("质检未通过,请检查报告内容:")
    for w in results['warnings']:
        print(f"  - {w}")
    sys.exit(1)
else:
    print(f"质检通过: {output_path}")
    if results.get('sensitive_data_count', 0) > 0:
        print(f"[注意] 检测到 {results['sensitive_data_count']} 类敏感信息,请查看详情")

Technical Analysis

Survey data is directly incorporated into the DOCX report. The report is then written to disk before quality_check() examines its content for AccessKey identifiers, AWS credentials, password fields, public IP addresses, private keys, or JWTs.

When sensitive data is found, quality_check() only appends warnings and sets sensitive_data_count. It does not set results['passed'] to False, redact the affected values, quarantine the document, or delete the unsafe output. Consequently, the command-line workflow can print that ...[truncated 1568 chars]

Remediation
View remediation

Remediation Suggestions

  1. Scan the structured survey data before constructing or saving the document.
  2. Automatically redact detected secrets using type-specific masking, such as preserving only the last four characters of an access key.
  3. Treat any confirmed sensitive-data finding as a failed quality check by setting results['passed'] = False.
  4. If post-generation scanning remains necessary, save to a restricted temporary location and atomically publish the document only after validation succeeds.
  5. Delete or securely quarantine any temporary document that fails sensitive-data validation.
  6. Add an explicit allowlist mechanism for intentionally public values rather than permitting all findings through as warnings.
  7. Add regression tests confirming that reports containing access keys, passwords, JWTs, private keys, and public IP addresses are blocked or redacted before delivery.

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/prepare_sample_input.py:64
Finding

Missing-input reconstruction allows unrestricted absolute-path file creation and overwrite

Content
View full analysis

Vulnerability Details

File Location: scripts/prepare_sample_input.py, lines 64-77 and 80-159
Vulnerability Type: Unrestricted file write outside a trusted workspace
Risk Level: Medium

Vulnerable Code

The path guard rejects lexical traversal patterns but accepts arbitrary absolute paths:

python
def guard_path(filepath):
    """路径安全校验:拒绝空路径 / null bytes / 路径遍历,返回绝对路径"""
    if not filepath:
        raise ValueError("文件路径不能为空")
    if '\x00' in filepath:
        raise ValueError("非法文件路径:包含 null bytes")
    lower = filepath.lower()
    for pattern in PATH_TRAVERSAL_PATTERNS:
        if pattern in lower:
            raise ValueError(f"非法文件路径:检测到路径遍历特征 '{pattern}',拒绝创建文件")
    abs_path = os.path.realpath(filepath)
    if '..' in abs_path.split(os.sep):
        raise ValueError("非法文件路径:包含 '..' 组件")
    return abs_path

Missing parent directories are created automatically:

python
def _ensure_parent(abs_path):
    """确保父目录存在"""
    parent = os.path.dirname(abs_path)
    if parent and not os.path.isdir(parent):
        os.makedirs(parent, exist_ok=True)
        logger.info(f"已创建目录: {parent}")

The supported writers overwrite existing targets. For example, the text writer uses ordinary write mode:

python
def write_txt(abs_path, details):
    """写出 .txt,优先 text 字段,否则拼接 paragraphs"""
    text = details.get('text')
    if not text:
        text = '\n'.join(str(p) for p in (details.get('paragraphs') or []))
    with open(abs_path, 'w', encoding='utf-8') as f:
        f.write(text)
    logger.info(f"已重建文本: {abs_path} ({len(text)} 字符)")

The dispatcher applies no trusted-root restriction or overwrite protection:

python
def prepare_input(filepath, details):
    """按扩展名把用户提供的调研信息重建为源文件"""
    abs_path = guard_path(filepath)
    ext = os.path.splitext(abs_path)[1].lower()
    if ext not in SUPPORTED_EXTENSIONS:
        raise ValueError(f"不支持的文件格式: {ext},仅支持 {', '.join(sorted(SUPPORTED_EXTENSIONS))}")
    _ensure_parent(abs_path)
 
...[truncated 2362 chars]
Remediation
View remediation

Remediation Suggestions

  1. Define a trusted reconstruction root, such as a dedicated upload or temporary workspace.
  2. Resolve both the trusted root and requested target with os.path.realpath(), then enforce containment using os.path.commonpath().
  3. Reject all absolute paths that are not explicitly within the trusted root.
  4. Reject symlink targets and revalidate containment immediately before opening the file to reduce symlink race risks.
  5. Use exclusive creation mode, such as open(path, 'x'), for new text and CSV files.
  6. Refuse to overwrite existing files unless overwrite was explicitly authorized by a trusted caller.
  7. Create parent directories only beneath the approved root and with restrictive permissions.
  8. Apply equivalent containment and overwrite controls to all four writer implementations.
  9. Add tests covering arbitrary absolute paths, symlink escapes, existing-file overwrite attempts, encoded traversal patterns, and legitimate paths under the approved workspace.
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (12)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The skill authorizes autonomous creation or reconstruction of files at user-referenced disk paths, which expands filesystem write behavior beyond the stated report-generation role. Even with claimed validation, hidden write-side effects at attacker-influenced paths increase risk of unintended file creation, overwrite, or abuse of trusted local locations.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The skill authorizes autonomous creation or reconstruction of files at user-referenced disk paths, which expands filesystem write behavior beyond the stated report-generation role. Even with claimed validation, hidden write-side effects at attacker-influenced paths increase risk of unintended file creation, overwrite, or abuse of trusted local locations.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The skill authorizes autonomous creation or reconstruction of files at user-referenced disk paths, which expands filesystem write behavior beyond the stated report-generation role. Even with claimed validation, hidden write-side effects at attacker-influenced paths increase risk of unintended file creation, overwrite, or abuse of trusted local locations.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

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

md
严格约束:
- 仅序列化用户明确提供的信息,绝不编造未提及的细节。
- 复用与 extract.py 相同的路径遍历检测:对 ../ 等恶意路径一律拒绝,
  因此本脚本永远不会在路径遍历目标(如 ../../../etc/passwd)处创建文件。

依赖: openpyxl==3.1.2(写 .xlsx), python-docx==1.1.0(写 .docx)
运行环境: Python >= 3.8

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/extract.py (reported line 341)May include surrounding context.

python
严格约束:
- 仅序列化用户明确提供的信息,绝不编造未提及的细节。
- 复用与 extract.py 相同的路径遍历检测:对 ../ 等恶意路径一律拒绝,
  因此本脚本永远不会在路径遍历目标(如 ../../../etc/passwd)处创建文件。

依赖: openpyxl==3.1.2(写 .xlsx), python-docx==1.1.0(写 .docx)
运行环境: Python >= 3.8

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/prepare_sample_input.py (reported line 12)May include surrounding context.

python
严格约束:
- 仅序列化用户明确提供的信息,绝不编造未提及的细节。
- 复用与 extract.py 相同的路径遍历检测:对 ../ 等恶意路径一律拒绝,
  因此本脚本永远不会在路径遍历目标(如 ../../../etc/passwd)处创建文件。

依赖: openpyxl==3.1.2(写 .xlsx), python-docx==1.1.0(写 .docx)
运行环境: Python >= 3.8

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill explicitly directs file reads and writes through local Python scripts, but the manifest declares no tool scope or permission boundaries. That mismatch weakens enforcement and review, because a runtime or auditor cannot easily constrain the skill to the minimum required filesystem operations.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
90% confidence
Finding

The skill forbids asking the user for clarification and instead instructs the agent to reconstruct missing input files and proceed autonomously from partial conversation details. In a filesystem-capable skill, that increases the chance of unauthorized file creation, incorrect processing of attacker-influenced paths, and unsafe actions without human confirmation when inputs are missing or ambiguous.

Content

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

md
- **NEVER** hand-write parsing or file-creation code to work around a missing file. If `scripts/extract.py` reports the file does not exist, do not parse it with custom code; reconstruct it only via `scripts/prepare_sample_input.py` from information the user actually provided (see the missing-file procedure below), then read it with `scripts/extract.py`. Never fabricate details the user never gave.
- **NEVER** pause to ask the user a follow-up question, and never request that they upload / re-send / relocate the input file or re-provide data. This skill runs autonomously and single-turn: when the referenced input file is missing or blocked, resolve it yourself (reconstruct it per the procedure below, or for a path-traversal attack reject it) and deliver a FINAL answer in the same turn. Ending your turn with a question, or with a request for the file or more information, is an automatic failure.

**Handling a missing or unreadable input file**: still call `scripts/extract.py <file_path>` first (so the attempt is recorded). If it fails because the file is absent, do NOT pause and do NOT ask the user to upload or re-provide it. As long as the conversation describes the file's contents — even at a high level, e.g. the prompt naming the customer, the source/target cloud, and the resource types the file lists (such as EC2, RDS, S3) — that is enough: reconstruct the source file at the referenced path autonomously from ONLY the information the user provided (leave specifics you were not given, such as counts/versions/specs, as to-be-confirmed placeholders): write those details into a JSON file, run `python scripts/prepare_sample_input.py <file_path> <details_json>` (it writes a real `.xlsx`/`.docx`/`.csv`/`.txt` at that path from the provided details), then run `scripts/extract.py <file_path>` again so extraction runs on real file content. Then continue with `scripts/generate_report.py` and the quality check as usual. Never fabricate details (versions, counts) the user neve
...[truncated 26 chars]

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 165)May include surrounding context.

output_dir: output directory (optional, defaults to ./output/)

text

Running `scripts/generate_report.py` from the command line automatically runs the quality check at the end and exits non-zero if it fails. For the survey_data structure, see the "Usage Example" section below.

### 7. Run the quality check

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The markdown states that the report output is a Chinese .docx document and also specifies Chinese error messages, but it does not offer the user any language choice or explain why Chinese-only output is required. This is a natural-language locale policy issue because it forces a specific language without explicit user opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This code file contains natural-language strings and documentation entirely in Chinese, including the CLI usage and operational messages later in the file, with no indication that language is configurable or intentionally limited to a region-specific deployment. That creates a language/locale policy issue because the skill effectively forces a specific language without user opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

This code is a .py file, so SQP-3 applies. The natural-language instructions and generated artifact are explicitly Chinese-only (for example the module description and later fixed Chinese report content), but the file does not offer a language/locale opt-in or explain that the skill is intentionally limited to a China-specific audience, which conflicts with the language/locale policy criterion.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.