Back to skill

Security audit

Alibabacloud Mcp Core Script Generate

Security checks for vulnerabilities and agentic risk

Overview

This skill is mostly aligned with generating Alibaba Cloud RunScript code, but its checker gives stronger safety assurances than it actually enforces and performs under-disclosed network validation.

Review this skill before installing. It does not show evidence of persistence, credential theft, or intentional destruction, but do not rely on its local PASS result as a complete sandbox guarantee. Treat generated write/delete cloud scripts as high-impact, inspect them manually, and be aware that validation may contact Alibaba metadata endpoints and may use broad shell-based fallback steps if MCP discovery fails.

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

Error
Location
scripts/check_sandbox.py:20
Finding

Incomplete sandbox validation permits prohibited capability access through whitelisted modules

Content
View full analysis

Vulnerability Details

File Location: scripts/check_sandbox.py, lines 20–24 and 54–137
Vulnerability Type: Incomplete security-policy enforcement
Risk Level: High

Vulnerable Code

python
IMPORT_WHITELIST = {
    "asyncio", "collections", "csv", "dataclasses", "datetime", "decimal",
    "enum", "fractions", "functools", "itertools", "json", "math", "re",
    "statistics", "string", "time", "typing", "uuid",
}

FORBIDDEN_FUNCS = [
    "eval", "exec", "compile", "__import__",
    "getattr", "setattr", "hasattr", "delattr",
    "globals", "locals", "vars",
]
python
def check(source: str) -> list[dict]:
    """Return list of {rule_id, line, message, fix} violations."""
    violations = []
    lines = source.splitlines()
    has_result = False

    for i, line in enumerate(lines, 1):
        stripped = line.strip()
        if not stripped or stripped.startswith("#"):
            continue

        # ── SEC-4001: forbidden import ──
        m = re.match(r'^(?:import|from)\s+([\w.]+)', stripped)
        if m:
            mod = m.group(1).split(".")[0]
            if mod not in IMPORT_WHITELIST:
                violations.append({
                    "rule_id": "SEC-4001", "line": i,
                    "message": f"Forbidden import: {mod}",
                    "fix": f"Remove 'import {mod}'. Allowed: {', '.join(sorted(IMPORT_WHITELIST))}. "
                           f"call_cli is pre-injected — do not import it.",
                })

        # ── OBF-3018: print() ──
        if re.search(r'\bprint\s*\(', stripped):
            violations.append({
                "rule_id": "OBF-3018", "line": i,
                "message": "print() disallowed",
                "fix": "Remove print(); assign data to 'result' instead (dict or list).",
            })

        # ── SEC-4002: eval / exec / reflection ──
        for fn in FORBIDDEN_FUNCS:
            if
...[truncated 3886 chars]
Remediation
View remediation

Remediation Suggestions

  1. Replace security-critical regular-expression validation with parsing through Python's ast module.
  2. Reject attribute paths that expose prohibited modules or capabilities, including chains such as uuid.os, sensitive frame attributes, and all disallowed dunder attributes.
  3. Use a positive allowlist for accessible members of each permitted module rather than trusting every attribute exported by a whitelisted top-level module.
  4. Resolve imported aliases and attribute aliases so that indirect forms cannot bypass checks.
  5. Ensure the local validator implements every rule promised by SKILL.md and references/runscript-contract.md, including direct-network restrictions, dunder-chain restrictions, dynamic formatting restrictions, blocked parameter values, and call_cli reachability.
  6. Add regression tests that must fail for at least:
    • import uuid; uuid.os.system(...)
    • Sensitive dunder and frame-attribute chains
    • Aliased or nested prohibited attribute access
    • Indirect network access through permitted modules
    • Scripts whose call_cli invocation is unreachable
  7. Treat local validation as defense in depth and retain equivalent enforcement in the remote runtime. Do not report a script as contract-compliant when a documented rule was not evaluated.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (12)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared description says this skill generates RunScript-compatible Python scripts from natural-language requests. The supplied code does not generate code from natural language or produce scripts at all. Its primary purpose is materially different: it audits existing Python files for sandbox compatibility and API parameter correctness. It also has undeclared capabilities such as reading local files/directories, printing pass/fail reports, and making outbound unauthenticated HTTP requests to Alibaba Cloud metadata endpoints. These are not merely supporting details of a code generator; they define a different tool altogether. Therefore the description does not accurately represent the code's actual behavior.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · references/runscript-contract.md (reported line 34)May include surrounding context.

md
Accessing sensitive modules via attribute chains on allowed modules is forbidden.

✅ `import uuid; uuid.uuid4()`
❌ `import uuid; uuid.os.system('rm -rf /')`

### No OS/Subprocess/Network

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · references/runscript-contract.md (reported line 34)May include surrounding context.

md
Accessing sensitive modules via attribute chains on allowed modules is forbidden.

✅ `import uuid; uuid.uuid4()`
❌ `import uuid; uuid.os.system('rm -rf /')`

### No OS/Subprocess/Network

Lp1

High
Category
MCP Least Privilege
Confidence
83% confidence
Finding

The script performs outbound HTTP requests to Alibaba Cloud metadata endpoints during validation, but the skill description centers on script generation rather than live network activity. In an agent context, undeclared network access can leak user-derived API targets or create unexpected external dependencies, making this a real security and trust issue even though the endpoint is public and unauthenticated.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
83% confidence
Finding

The script performs outbound HTTP requests to Alibaba Cloud metadata endpoints during validation, but the skill description centers on script generation rather than live network activity. In an agent context, undeclared network access can leak user-derived API targets or create unexpected external dependencies, making this a real security and trust issue even though the endpoint is public and unauthenticated.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill instructs fallback to external HTTP fetches and shell-based local extraction (curl, python3 -c, grep, jq) even though the skill is framed as producing sandbox-compatible code using constrained AlibabaCloud core tooling. This expands the trusted execution surface to arbitrary local shell tooling and external network content, creating risk of unsafe command construction, policy bypass, and inconsistent behavior outside the declared sandbox model.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The guardrail forbids using any MCP server except local alibabacloud-core, but earlier instructions authorize non-MCP external HTTP and shell-based fallback methods. This contradiction weakens operator trust and can be exploited to justify policy exceptions, leading the agent to access unapproved resources or execute local commands under the guise of documented fallback behavior.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manifest frames the skill as a code generator for sandbox-compatible scripts. In this file, the implementation imports urllib and later uses it to fetch remote API definitions for validation, which is a materially different behavior from generation and broadens the skill into a networked linter/validator.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
82% confidence
Finding

The hardcoded external endpoint is used for live metadata retrieval, confirming external transmission capability in a component that otherwise appears to be a local checker. This matters in the skill context because the tool processes user-provided script content and API identifiers, so outbound requests may unexpectedly expose operational intent and couple security validation to a remote service.

Content

Scanner excerpt · scripts/check_sandbox.py (reported line 43)May include surrounding context.

python
CLI_META_PRODUCTS = {"configure", "plugin", "ossutil", "autocompletion"}

# ── API Metadata (public endpoint, no auth) ──
API_META_URL = "https://api.aliyun.com/meta/v1/products/{product}/versions/{version}/apis/{action}/api.json"
_API_DEF_CACHE = {}  # in-memory cache: "Product.Version.Action" → api def dict

SDK_PATTERNS = [

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The helper fetches remote API metadata at runtime, which introduces undeclared external communication and expands the attack surface beyond pure local linting. Even without credentials, user-supplied product/version/action values are transmitted to a third party, and runtime validation now depends on network availability and trust in remote content.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
79% confidence
Finding

The function-level documentation explicitly states that remote fetches occur for each unique product/version/action, reinforcing that external transmission is part of normal execution. Repeated outbound requests based on analyzed content can disclose user activity patterns and create a privacy and reliability concern in a security-checking helper.

Content

Scanner excerpt · scripts/check_sandbox.py (reported line 320)May include surrounding context.

python
def _check_api_params(source: str, violations: list[dict]):
    """Validate call_cli params against OpenAPI definitions from public metadata endpoint.

    Fetches https://api.aliyun.com/meta/v1/... (no auth, no disk writes) for each
    unique product/version/action, then checks:
      - API-PARAM-UNKNOWN:  param name not in API definition
      - API-PARAM-REQUIRED: required param missing

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The code makes outbound requests without prominent user-facing disclosure near the operation, which weakens transparency and informed consent. In an agent toolchain, silent network activity is risky because users may assume analysis is fully local while their inputs are being transmitted externally.

Content

No source excerpt is available for this finding.