Back to skill

Security audit

minimax-media (James)

Security checks for vulnerabilities and agentic risk

Overview

The skill provides MiniMax image and speech generation, but it has under-scoped network and credential handling that users should review before installing.

Install only if you are comfortable sending prompts and TTS text to MiniMax and storing a MiniMax API key in your environment. Do not set MINIMAX_BASE_URL unless you fully trust the endpoint, avoid submitting secrets or regulated data, and prefer a revised version that validates the MiniMax host, validates image download URLs and sizes, and uses safer temporary-file creation.

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 (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/minimax_media.py:18
Finding

Unrestricted API Endpoint Override Can Exfiltrate Credentials and User Content

Content
View full analysis

Vulnerability Details

File Location: scripts/minimax_media.py, lines 18-30 and 57-76
Vulnerability Type: Unrestricted sensitive-data transmission endpoint
Risk Level: High

Vulnerable Code

python
API_KEY = os.environ.get('MINIMAX_API_KEY', '')
BASE_URL = os.environ.get('MINIMAX_BASE_URL', 'https://api.minimax.io').rstrip('/v1').rstrip('/')


def generate_image(prompt: str, output_path: str = None) -> dict:
    """Use MiniMax image-01 to generate an image."""
    url = f"{BASE_URL}/v1/image_generation"
    headers = {
        'Authorization': f'Bearer {API_KEY}',
        'Content-Type': 'application/json'
    }
    payload = {
        'model': 'image-01',
        'prompt': prompt
    }
    resp = requests.post(url, headers=headers, json=payload, timeout=60)
python
def text_to_speech(text: str, voice_id: str = 'female-tianmei', speed: float = 1.0, output_path: str = None) -> dict:
    """Use MiniMax speech-2.8-hd to generate speech."""
    url = f"{BASE_URL}/v1/t2a_v2"
    headers = {
        'Authorization': f'Bearer {API_KEY}',
        'Content-Type': 'application/json'
    }
    payload = {
        'model': 'speech-2.8-hd',
        'text': text,
        'stream': False,
        'output_format': 'hex',
        'voice_setting': {
            'voice_id': voice_id,
            'speed': speed,
            'vol': 1,
            'pitch': 0
        },
        'language_boost': 'auto'
    }
    resp = requests.post(url, headers=headers, json=payload, timeout=60)

Technical Analysis

Sending the API credential and user-supplied prompts or TTS text over the network is necessary for the declared MiniMax functionality. However, MINIMAX_BASE_URL accepts an arbitrary value without validating its scheme or hostname. Both API operations then attach the MiniMax bearer credential and send user content to that endpoint.

This exceeds the minimum pr ...[truncated 1416 chars]

Remediation
View remediation

Remediation Suggestions

  • Require HTTPS and validate the parsed URL before transmitting any credential.
  • Restrict credential-bearing requests to an explicit hostname allowlist, such as api.minimax.io.
  • Reject URLs containing embedded credentials, fragments, unexpected ports, or unsupported schemes.
  • If custom endpoints are a legitimate requirement, require explicit opt-in and use separate endpoint-specific credentials rather than automatically forwarding MINIMAX_API_KEY.
  • Disable automatic redirects for authenticated API requests, or validate the destination of every redirect before following it.
  • Fail before making a request when MINIMAX_API_KEY is empty.
  • Replace the trailing-character operation with proper URL parsing and path normalization.
  • Document that prompts and TTS text are transmitted to MiniMax and should not contain secrets unless users accept that disclosure.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/minimax_media.py:38
Finding

Unvalidated API-Supplied Image URL Enables Server-Side Request Forgery

Content
View full analysis

Vulnerability Details

File Location: scripts/minimax_media.py, lines 38-45
Vulnerability Type: Server-side request forgery and unbounded remote download
Risk Level: Medium

Vulnerable Code

python
    data = resp.json()
    image_urls = data.get('data', {}).get('image_urls', [])
    if not image_urls:
        return {"error": "No image URL returned"}

    # Download image
    img_resp = requests.get(image_urls[0], timeout=60)
    if img_resp.status_code != 200:
        return {"error": f"Failed to download image: {img_resp.status_code}"}

Technical Analysis

The script treats the first URL returned by the API as trusted and sends a GET request without validating the URL scheme, hostname, destination address, redirect chain, content type, or response size. The requests library follows redirects by default.

If the API endpoint is compromised or replaced through MINIMAX_BASE_URL, it can return a URL targeting loopback services, private network hosts, link-local cloud metadata services, or another attacker-selected destination. DNS rebinding and redirects may also bypass simplistic initial-host checks unless each resolved address and redirect destination is validated.

The complete response is buffered in img_resp.content, so a remote server can also return a very large body and consume substantial process memory before it is written to disk.

Attack Path

  1. An attacker controls or compromises the configured API endpoint, or otherwise manipulates its image-generation response.
  2. The endpoint returns an image_urls entry pointing to an internal service, loopback address, link-local metadata endpoint, or redirector.
  3. The victim's machine sends the GET request from its own network context.
  4. The script follows redirects and retrieves the response without destination validation.
  5. The response is buffered and written to a local file; the output path and response size are re ...[truncated 687 chars]
Remediation
View remediation

Remediation Suggestions

  • Permit downloads only over HTTPS from an explicit allowlist of trusted MiniMax image CDN hosts.
  • Parse and validate the URL before issuing the request.
  • Resolve the hostname and reject loopback, private, link-local, multicast, reserved, and unspecified addresses for both IPv4 and IPv6.
  • Disable redirects or validate every redirect destination and its resolved addresses before following it.
  • Stream the response in bounded chunks rather than accessing img_resp.content.
  • Enforce a strict maximum image size and abort once the limit is exceeded.
  • Validate the response Content-Type against supported image formats and verify the downloaded file signature before saving it.
  • Apply separate connection and read timeouts and handle request exceptions safely.

T09 · Insecure Skill Coding Practices

Note
Location
scripts/minimax_media.py:47
Finding

Insecure Temporary-File Creation Permits Symlink Race Attacks

Content
View full analysis

Vulnerability Details

File Location: scripts/minimax_media.py, lines 47-51 and 91-95
Vulnerability Type: Predictable temporary-file race
Risk Level: Low

Vulnerable Code

python
    if output_path is None:
        output_path = tempfile.mktemp(suffix='.png')

    with open(output_path, 'wb') as f:
        f.write(img_resp.content)
python
    if output_path is None:
        output_path = tempfile.mktemp(suffix='.mp3')

    with open(output_path, 'wb') as f:
        f.write(audio_bytes)

Technical Analysis

tempfile.mktemp() returns an unused pathname but does not atomically create or reserve the file. A time-of-check-to-time-of-use window therefore exists between choosing the pathname and opening it. Another local process can create a file or symbolic link at the selected path before open() executes.

Because open(output_path, 'wb') follows symbolic links and truncates the destination, a successful race can redirect generated media into another file writable by the user running the Skill.

Attack Path

  1. A local attacker monitors or predicts temporary filenames in the shared temporary directory.
  2. After mktemp() returns but before open() executes, the attacker creates a symbolic link at that path.
  3. The symbolic link points to a target file writable by the victim account.
  4. The script follows the link and opens the target in truncating binary-write mode.
  5. Generated image or audio bytes overwrite the target file.

Impact Assessment

Exploitation can overwrite or corrupt files writable by the invoking user. It does not bypass that user's filesystem permissions, so it does not independently provide privilege escalation. On multi-user systems or where a local adversary can manipulate the temporary directory, it may damage application data, configuration files, or other user-owned resources.

Remediation
View remediation

Remediation Suggestions

  • Replace tempfile.mktemp() with tempfile.NamedTemporaryFile(delete=False, suffix=...) and write through the already opened file object.
  • Alternatively, use tempfile.mkstemp(), retain the returned descriptor, and write through that descriptor without reopening the pathname.
  • Ensure temporary files are created with restrictive user-only permissions.
  • Close descriptors safely through a context manager and remove partial files after write or decoding failures.
  • For caller-provided output paths, consider refusing symbolic links and using platform-appropriate atomic creation or replacement semantics.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (9)

Tainted flow: 'url' from os.environ.get (line 61, credential/environment) → requests.post (network output)

Critical
Category
Data Flow
Confidence
94% confidence
Finding

The request destination is derived from MINIMAX_BASE_URL, an environment variable that can be altered to point at an attacker-controlled host. Because the code sends the Authorization bearer token and user prompt to that URL, this can enable secret exfiltration and arbitrary external data transmission if the runtime environment is compromised or misconfigured.

Content

Scanner excerpt · scripts/minimax_media.py (reported line 32)May include surrounding context.

python
'model': 'image-01',
        'prompt': prompt
    }
    resp = requests.post(url, headers=headers, json=payload, timeout=60)
    if resp.status_code != 200:
        return {"error": f"API error {resp.status_code}: {resp.text[:200]}"}

Tainted flow: 'url' from os.environ.get (line 61, credential/environment) → requests.post (network output)

Critical
Category
Data Flow
Confidence
94% confidence
Finding

As with image generation, the TTS API endpoint is built from an environment-controlled base URL and is used with an Authorization header. A modified MINIMAX_BASE_URL could redirect requests, leaking the API key and all submitted text to an attacker-controlled service.

Content

Scanner excerpt · scripts/minimax_media.py (reported line 79)May include surrounding context.

python
},
        'language_boost': 'auto'
    }
    resp = requests.post(url, headers=headers, json=payload, timeout=60)
    if resp.status_code != 200:
        return {"error": f"HTTP error {resp.status_code}: {resp.text[:200]}"}

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The README instructs users to send prompts and text-to-speech content to a third-party API using an API key, but it does not disclose that user-provided content and related metadata will leave the local environment. This can lead users to unknowingly transmit sensitive or regulated data to an external service, creating privacy, compliance, and data-handling risk.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding

The skill invokes Python code that uses environment variables and external network access, but the manifest does not declare any tool scope or permissions. This weakens security review and user consent because consumers cannot clearly see that the skill may read secrets such as MINIMAX_API_KEY and transmit user data to a remote service.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill description explains functionality but does not warn that prompts or TTS text are sent to the external MiniMax API and that generated media is stored locally. This can cause unintentional disclosure of sensitive user content and unexpected local file creation, especially if users assume processing is local-only.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code sends user-provided prompt/text data to a remote MiniMax API via HTTP requests and writes returned media to local files, but there is no confirmation prompt, print/log disclosure, or inline warning about those safety-relevant actions. The top-level usage docstring describes commands only and does not inform users that their content is transmitted to an external service and saved to disk.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · scripts/minimax_media.py (reported line 32)May include surrounding context.

python
'model': 'image-01',
        'prompt': prompt
    }
    resp = requests.post(url, headers=headers, json=payload, timeout=60)
    if resp.status_code != 200:
        return {"error": f"API error {resp.status_code}: {resp.text[:200]}"}

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · scripts/minimax_media.py (reported line 79)May include surrounding context.

python
'model': 'image-01',
        'prompt': prompt
    }
    resp = requests.post(url, headers=headers, json=payload, timeout=60)
    if resp.status_code != 200:
        return {"error": f"API error {resp.status_code}: {resp.text[:200]}"}

Tainted flow: 'image_urls' from requests.post (line 37, network input) → requests.get (network output)

Medium
Category
Data Flow
Confidence
89% confidence
Finding

The code blindly fetches image_urls[0] returned by the upstream API, causing a second network request to an untrusted URL. If the API response is malicious or tampered with, this creates an SSRF-style primitive or at minimum allows unexpected outbound requests to attacker-chosen locations.

Content

Scanner excerpt · scripts/minimax_media.py (reported line 42)May include surrounding context.

python
return {"error": "No image URL returned"}
    
    # 下載圖片
    img_resp = requests.get(image_urls[0], timeout=60)
    if img_resp.status_code != 200:
        return {"error": f"Failed to download image: {img_resp.status_code}"}