Back to skill

Security audit

Byted Seedream Image Generate

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent Seedream image-generation integration, but it prints the full API bearer token and request body to console output during normal use.

Review before installing. Use this only with API keys you are comfortable exposing to local console or agent logs until the logging is fixed, and avoid sensitive prompts, private image URLs, or confidential reference material. Rotate any API key previously used with this version if its output may have been captured.

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/seedream_image_generate.py:153
Finding

API Bearer Token Disclosed in Console Output

Content
View full analysis

Vulnerability Details

File Location: scripts/seedream_image_generate.py, lines 153–162
Vulnerability Type: Plaintext credential exposure through logging
Risk Level: High

Vulnerable Code

python
# 打印完整请求入参
print("\n" + "="*80)
print("📤 完整 API 请求入参:")
print("="*80)
print(f"URL: {url}")
print(f"Headers: {json.dumps(_get_headers(), indent=2, ensure_ascii=False)}")
print(f"Request Body: {json.dumps(body, indent=2, ensure_ascii=False)}")
print("="*80 + "\n")

async with httpx.AsyncClient(timeout=float(timeout)) as client:
    response = await client.post(url, headers=_get_headers(), json=body)

The printed headers are generated by the following code at lines 95–104:

python
def _get_headers() -> dict:
    """
    Build API request headers
    """
    if not API_KEY:
        raise ValueError(
            "Please set ARK_API_KEY or MODEL_IMAGE_API_KEY or MODEL_AGENT_API_KEY environment variable"
        )
    return {
        "Content-Type": "application/json",
        "Authorization": f"Bearer {API_KEY}",
    }

Technical Analysis

The script serializes and prints the complete HTTP header dictionary immediately before making an API request. Because _get_headers() places the configured API key directly into the Authorization header, the output contains the plaintext bearer token.

The credential can consequently be retained in terminal output, CI/CD logs, orchestration logs, monitoring platforms, Agent transcripts, or other systems that capture standard output. The request body is also printed and may expose user prompts, reference-image URLs, and generation settings.

Bearer tokens generally confer access based on possession. An attacker does not need to recover a password or bypass another authentication control after obtaining the logged token.

Attack Path

  1. An operator configures ARK_API_KEY, MODEL_IMAGE_API_KEY, or MODEL_AGENT_API_KEY.
  2. The operator or an automated Agent invokes image generation.
  3. `_g ...[truncated 1065 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove all logging of complete request headers. Authorization headers must never be written to standard output or routine application logs.
  2. If diagnostic header logging is necessary, construct a sanitized copy and replace sensitive values before serialization:
python
safe_headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer [REDACTED]",
}
print(f"Headers: {json.dumps(safe_headers, indent=2)}")
  1. Disable verbose URL, header, and request-body logging by default. Place sanitized diagnostics behind an explicit debug option.
  2. Redact sensitive request-body fields, including prompts and reference-image URLs, or avoid logging the body entirely.
  3. Rotate any API keys used while the vulnerable logging behavior was active, especially if output was retained by shared terminals, CI systems, Agent transcripts, or centralized logging services.
  4. Review existing logs and transcripts for exposed keys, restrict access to those records, and delete them according to the applicable retention policy.
  5. Add automated tests or static-analysis rules that reject logging of Authorization, API-key, token, and credential values.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (8)

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The code logs the full Authorization header and full request body before sending the API call, which exposes the bearer token and potentially sensitive user prompts, image URLs, and tool-related inputs to stdout or captured logs. In agent, CI, or shared execution environments, these logs may be retained or visible to other operators, enabling credential theft and disclosure of sensitive user data.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill documents use of environment variables for API keys and a remote API endpoint, but it does not declare any explicit tool scope or permission boundaries. This creates a transparency and governance gap: an orchestrator or reviewer cannot easily determine that the skill needs network access and secret-bearing environment access before invocation.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The top-level description is broad enough to match many generic creative-image requests, which can cause the agent to invoke this skill in situations where a local or safer alternative would suffice. Overbroad routing increases unnecessary exposure of user prompts and reference data to an external 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 describes external image generation features, reference-image handling, and optional web search, but it does not clearly warn that prompts, reference image URLs, and search-derived content are transmitted to a third-party provider. This omission can cause unintentional data disclosure, especially if users include sensitive personal, confidential, or proprietary information in prompts or images.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The "When to Use This Skill" section lists many inclusive triggers but no exclusion conditions, consent checks, or privacy boundaries. In an agentic environment, this makes accidental invocation more likely and can lead to sending sensitive prompts, image URLs, or derived search queries to external services without clear need.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
82% confidence
Finding

The function sends user-supplied prompt content and optional image/tool-related parameters over HTTP to an external service. Although network access is part of the skill's purpose, the code lacks a clear disclosure that user content and referenced inputs are sent off-box, which is especially relevant when prompts or image references may contain sensitive data.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest describes an image-generation skill focused on creating images from prompts and artistic styles. However, the CLI exposes a --web-search option and passes tools: [{"type": "web_search"}] to the model, enabling external information retrieval that is not declared in the skill description and is not an obvious requirement for basic image generation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

This file includes user-visible messages in Chinese such as the request-construction and API-request logs, while the rest of the CLI is primarily in English. For all file types, forcing a specific language without opt-in can violate language/locale policy when no language selection or justification is provided.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.