Back to skill

Security audit

public-opinion-report

Security checks for vulnerabilities and agentic risk

Overview

The skill does what it claims, but it handles API credentials and sends user report content over an internal plaintext HTTP service, which needs review before installation.

Review this skill before installing. Only use it in an environment where the Midu internal HTTP endpoint is trusted, do not put secrets or regulated content in report prompts unless approved, and prefer an updated version that uses HTTPS, requires explicit secure MIDU_API_KEY configuration, and documents secret handling.

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/report.py:8
Finding

API Credential and User Report Content Transmitted over Plaintext HTTP

Content
View full analysis

Vulnerability Details

File Location: scripts/report.py, lines 8-29 and 43-55
Vulnerability Type: Plaintext transmission of sensitive information
Risk Level: High

Vulnerable Code

python
API_BASE_URL = "http://intra-znjs-yqt-agent-wx-beta.midu.cc".rstrip("/")


def _resolve_api_key(base_url: str) -> str:
    """Prefer MIDU_API_KEY; otherwise GET {base}/apiKey."""
    key = os.environ.get("MIDU_API_KEY")
    if key and key.strip():
        return key.strip()
    url = f"{base_url}/apiKey"
    response = requests.get(url, timeout=60)
    response.raise_for_status()
    text = response.text.strip()
    if not text:
        return ""
    try:
        data = json.loads(text)
        if isinstance(data, dict):
            for k in ("key", "api_key", "token", "data"):
                v = data.get(k)
                if isinstance(v, str) and v.strip():
                    return v.strip()
    except json.JSONDecodeError:
        pass
    return text
python
def generate_report(message: str) -> dict:
    """Generate a public opinion analysis report.
    Args:
        query: The query to generate a public opinion analysis report.
    Returns:
        A dictionary containing the public opinion analysis report. The result is in Markdown format.
    """
    root = API_BASE_URL
    api_key = _resolve_api_key(root)
    chat_url = f"{root}/api/chat"
    headers = {"Content-Type": "application/json", "podName": "public-opinion-report-skill-user", "podNameSpace": "beta-nlp"}
    if api_key:
        headers["Authorization"] = "Bearer %s" % api_key

    body = {"messages": [{"role": "user", "content": message}]}
    response = requests.post(chat_url, json=body, headers=headers, timeout=1200)
    response.raise_for_status()
    data = response.json()

Technical Analysis

The service base URL is explicitly configured with the unencrypted http:// s ...[truncated 2674 chars]

Remediation
View remediation

Remediation Suggestions

  1. Replace the service URL with an authenticated HTTPS endpoint:
    python
    API_BASE_URL = "https://intra-znjs-yqt-agent-wx-beta.midu.cc".rstrip("/")
    
  2. Ensure the service presents a certificate issued for the expected hostname. Retain certificate verification and never set verify=False.
  3. Reject any configured base URL whose scheme is not HTTPS, preferably using urllib.parse.urlparse.
  4. Restrict or disable redirects. If redirects are required, verify that every destination retains HTTPS and belongs to an explicit hostname allowlist.
  5. Remove the automatic /apiKey fallback. Require MIDU_API_KEY through secure configuration and fail closed when it is absent:
    python
    api_key = os.environ.get("MIDU_API_KEY", "").strip()
    if not api_key:
        raise RuntimeError("MIDU_API_KEY is required")
    
  6. Store the API key in an approved secret-management facility. If a local configuration file must be used, enforce restrictive permissions and prevent it from being committed or logged.
  7. Scope the API credential to only the report-generation operation, apply expiration and rotation, and revoke any credential previously transmitted over HTTP.
  8. Avoid including credentials, full response bodies, or sensitive report prompts in errors and operational logs.
  9. Add automated tests that fail if the configured endpoint uses HTTP or if a redirect attempts to downgrade an HTTPS request.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • 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 (11)

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The guide instructs users to retrieve an API key from an internal endpoint over plain HTTP, which exposes the request and returned credential to interception or modification by anyone on the network path. Because this is a credential bootstrap step, a man-in-the-middle attacker could steal the key or substitute a malicious value, leading to unauthorized API use or compromise of downstream systems.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill declares it needs an environment variable and uses an internal network API, but it does not explicitly declare tool scope or permissions boundaries. This can lead to overbroad execution in agent environments, where the skill may access network and secret material without clear user-visible authorization semantics.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill instructs users to send arbitrary report requests to an internal service using an API key, but it does not warn that the user's prompt content may be transmitted to an internal network endpoint. Users may unknowingly submit sensitive, regulated, or proprietary content to a backend service, creating confidentiality and compliance risk.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The instructions tell users to place a long-lived API key directly into a local JSON configuration file without guidance on file permissions, secret rotation, or safer storage options. This increases the chance the key is exposed through weak filesystem permissions, backups, logs, screenshots, or accidental check-in to version control.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill performs credential discovery by requesting an API key from a separate endpoint when the environment variable is absent. This expands the skill's behavior beyond simple report generation and can enable unauthorized credential retrieval or misuse if the endpoint is exposed, misconfigured, or intercepted; the risk is increased because the base URL uses plain HTTP rather than HTTPS.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill transmits data over the network to retrieve credentials and submit user content without any explicit disclosure, consent, or clear indication to the caller. In a skill context, users may reasonably expect local processing, so silent transmission of prompts and possible sensitive content to a remote service creates privacy and data-handling risk, especially since the configured service uses HTTP.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
88% confidence
Finding

The skill sends the user-supplied message and optional bearer token to an external service, which is expected for this skill's function, but still constitutes a real data egress point. The context makes the transmission functionally necessary, yet the danger is elevated by the use of an internal plain-HTTP endpoint because sensitive prompt contents and credentials could be exposed in transit or to unintended internal systems.

Content

Scanner excerpt · scripts/report.py (reported line 56)May include surrounding context.

python
headers["Authorization"] = "Bearer %s" % api_key

    body = {"messages": [{"role": "user", "content": message}]}
    response = requests.post(chat_url, json=body, headers=headers, timeout=1200)
    response.raise_for_status()
    data = response.json()
    if "result" not in data:

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
76% confidence
Finding

The report type guidance presents example invocations only in Chinese, which can imply a preferred language behavior without explicitly offering users a language or locale choice. Under the language/locale policy rule, forcing or implicitly requiring a specific language without opt-in can be a natural-language policy issue.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The test example uses a Chinese prompt (编写法国旅游的快评) as the only shown interaction, which can imply a fixed language expectation. The file does not state that the skill is China/Chinese-specific or offer users a language choice, creating a potential locale-policy issue in natural-language guidance.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
72% confidence
Finding

The file includes natural-language operational guidance in Chinese while other user-facing strings are in English, with no indication that the skill is region-specific or that users can choose a language. This can violate a language/locale policy when a specific language is imposed without opt-in or justification.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
98% confidence
Finding

The code computes extra keys by allowing only the singular key 'message', but the emitted error says only 'messages' is allowed. This is an active contradiction between the inline user-facing documentation and the real behavior, which can mislead integrators about the required input format.

Content

No source excerpt is available for this finding.