Back to skill

Security audit

Datayes Stock Data

Security checks for vulnerabilities and agentic risk

Overview

The skill matches its Datayes stock-data purpose, but it needs Review because a Datayes API token could be forwarded outside the intended host allowlist during redirects.

Review before installing if the Datayes token has meaningful quota or account value. Use a minimal-scope, revocable token, and prefer fixing redirect handling first by rejecting cross-origin redirects or stripping Authorization on redirected requests.

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/datayes_api.py:40
Finding

Bearer Token Can Be Forwarded to an Untrusted Host Through HTTP Redirects

Content
View full analysis
Any: body = None headers = { "Authorization": f"Bearer {token}", "Accept": "application/json", } if payload is not None: body = json.dumps(payload).encode("utf-8") headers["Content-Type"] = "application/json" request = urllib.request.Request(url=url, data=body, headers=headers, method=method) try: with urllib.request.urlopen(request, timeout=TIMEOUT) as response: ``` The initial business API URL is validated as follows: ```python def _validate_http_url(http_url: str) -> str: parsed = urllib.parse.urlparse(http_url) if parsed.scheme != "https": raise DatayesError(f"Resolved httpUrl must use https: {http_url}") if not parsed.netloc: raise DatayesError(f"Resolved httpUrl is missing a host: {http_url}") host = (parsed.hostname or "").lower() if host not in ALLOWED_HTTP_HOSTS: allowed_hosts = ", ".join(sorted(ALLOWED_HTTP_HOSTS)) raise DatayesError( f"Resolved httpUrl host {host or ''} is not trusted. Allowed hosts: {allowed_hosts}" ) return http_url ``` ### Technical Analysis The Skill needs authenticated network access to provide its declared Datayes stock-data functionality. Passing `DATAYES_TOKEN` to the fixed Datayes specification endpoint and validated Datayes business endpoints is therefore functionally justified and does not, by itself, exceed minimum required privileges. However, `_validate_http_url()` validates only the initial URL. The subsequent call to `urllib.request.urlopen()` uses Python's default redirect handling. The request already contains the sensitive `Au ...[truncated 2134 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • 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 (8)

Tainted flow: 'request' from os.environ.get (line 49, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/datayes_api.py (reported line 51)May include surrounding context.

python
request = urllib.request.Request(url=url, data=body, headers=headers, method=method)
    try:
        with urllib.request.urlopen(request, timeout=TIMEOUT) as response:
            charset = response.headers.get_content_charset() or "utf-8"
            return json.loads(response.read().decode(charset))
    except urllib.error.HTTPError as exc:

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

声明描述的是一个面向用户的股票数据查询技能,核心能力应是调用 Datayes 获取证券行情、财务和估值等信息。而实际代码只是测试代码:它构造模拟 spec,验证 _normalize_params 是否按必填/默认值规则处理参数,并验证 _validate_http_url 是否拒绝非 HTTPS 或非 Datayes 可信主机 URL。该代码片段没有实现或展示任何实际的股票行情、财务、估值、资金流向或公司资料查询行为,主用途与声明明显不一致。因此应判定为描述与行为不匹配。

Content

No source excerpt is available for this finding.

Env Variable Harvesting

High
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.

Content

Scanner excerpt · scripts/smoke_test.py (reported line 24)May include surrounding context.

python
def run_json(args: list[str]) -> Any:
    cmd = [sys.executable, str(SCRIPT), *args]
    result = subprocess.run(cmd, cwd=ROOT, text=True, capture_output=True, env=os.environ.copy())
    if result.returncode != 0:
        raise SmokeTestError(result.stderr.strip() or result.stdout.strip() or f"Command failed: {' '.join(cmd)}")
    return json.loads(result.stdout)

Env Variable Harvesting

High
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.

Content

Scanner excerpt · scripts/smoke_test.py (reported line 102)May include surrounding context.

python
def run_json(args: list[str]) -> Any:
    cmd = [sys.executable, str(SCRIPT), *args]
    result = subprocess.run(cmd, cwd=ROOT, text=True, capture_output=True, env=os.environ.copy())
    if result.returncode != 0:
        raise SmokeTestError(result.stderr.strip() or result.stdout.strip() or f"Command failed: {' '.join(cmd)}")
    return json.loads(result.stdout)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill requires environment access, shell execution, and outbound network access but does not declare an explicit tool scope such as allowed tools or permissions. That omission weakens least-privilege controls and can let the skill run with broader capabilities than reviewers or orchestrators expect, which matters because it handles a bearer token and makes authenticated external requests.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/smoke_test.py (reported line 24)May include surrounding context.

python
def run_json(args: list[str]) -> Any:
    cmd = [sys.executable, str(SCRIPT), *args]
    result = subprocess.run(cmd, cwd=ROOT, text=True, capture_output=True, env=os.environ.copy())
    if result.returncode != 0:
        raise SmokeTestError(result.stderr.strip() or result.stdout.strip() or f"Command failed: {' '.join(cmd)}")
    return json.loads(result.stdout)

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/smoke_test.py (reported line 97)May include surrounding context.

python
assert_true(any(row.get("ticker") == "601988" for row in income_rows), "fdmt_is_new_lt returned unexpected ticker set")
    checks.append("fdmt_is_new_lt_without_field")

    invalid = subprocess.run(
        [sys.executable, str(SCRIPT), "stock_search", "--param", "keyword=比亚迪"],
        cwd=ROOT,
        text=True,

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

This markdown file presents all operational guidance and examples exclusively in Chinese. Under the policy rule for language/locale, forcing a specific language without offering a user choice or documenting a justified locale constraint can be a natural-language policy violation.

Content

No source excerpt is available for this finding.