Back to skill

Security audit

nano-banana2

Security checks for vulnerabilities and agentic risk

Overview

This image-generation skill is coherent, but it needs review because it can persist and automatically read a saved API key while sending prompts and image URLs to a third-party service.

Install only if you are comfortable sending prompts, reference-image URLs, and an API key to agent.mathmind.cn. Prefer a session environment variable over saving the key locally, avoid the documented echo pipeline for real keys, and do not allow the skill to read ~/.config/nano-banana2/.env unless you explicitly choose local-key mode.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (3)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/generate.sh:92
Finding

API Key and Request Data May Be Forwarded Through HTTP Redirects

Content
View full analysis
&1) ``` ### Technical Analysis The script uses curl's `--location` option, allowing the remote API server to control redirect destinations. The request contains a custom `x-api-key` header and a JSON body containing the user's prompt and reference-image URLs. Custom headers specified with `--header` can remain associated with redirected requests. Consequently, a compromised, malicious, or misconfigured API endpoint could issue a redirect to an attacker-controlled host and cause sensitive request information to be transmitted outside the declared endpoint. Following redirects is not necessary for the Skill's core image-generation functionality when the API has a fixed, documented endpoint. ### Attack Path 1. The user invokes `scripts/generate.sh` with a valid API key and image-generation parameters. 2. The script sends the request to the declared API endpoint. 3. The endpoint, or infrastructure controlling it, returns an HTTP redirect to an attacker-controlled host. 4. Curl follows the redirect because `--location` is enabled. 5. The redirected request may expose the custom API-key header, prompt, reference-image URLs, or other request data to the attacker-controlled destination. ### Impact Assessment Successful exploitation could disclose: - The user's `X_API_KEY`, potentially allowing unauthorized API use and consumption of paid credits. - User prompts, which may contain confidential or proprietary information. - Reference-image URLs, including potentially sensitive or access-bearing URLs. The issue does not grant local system privileges or arbitrary code execution. I ...[truncated 96 chars]
Remediation
View remediation
&1) ``` - Treat any 3xx response as an error and report it without following the destination. - If redirects are operationally unavoidable, resolve and validate each redirect target against an exact HTTPS origin allowlist before sending credentials. - Never forward `x-api-key` to a different scheme, hostname, or port. - Consider using `--proto '=https'` to prevent protocol downgrade. ]]>

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
SKILL.md:243
Finding

Interaction Instructions Contradict Explicit Consent for Local Credential Access

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Note
Location
SKILL.md:203
Finding

Documented Standard-Input Command Can Expose the API Key in Shell History

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (26)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The declared purpose is image generation, but the skill also instructs persistence and ingestion of API credentials from stdin/TTY and local files. That mismatch is security-relevant because it expands behavior into secret handling and local state management that users may not expect from the description, increasing the chance of accidental credential exposure or unsafe invocation.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
96% confidence
Finding

The skill explicitly supports storing the API key in a local .env file. Plaintext credential storage in a predictable path creates a real credential access risk from other local processes, accidental backups, sync tools, or later compromise of the agent workspace.

Content

Scanner excerpt · SKILL.md (reported line 14)May include surrounding context.

md
secrets:
    primary: "X_API_KEY"
  storage:
    optional: ["~/.config/nano-banana2/.env (only when user explicitly enables --use-local-key)"]
---

## 安全声明(ClawHub 扫描友好)

Credential Access

High
Category
Privilege Escalation
Confidence
97% confidence
Finding

The setup instructions tell users to write X_API_KEY directly into ~/.config/nano-banana2/.env. That creates a durable plaintext secret on disk, which meaningfully increases the chance of unauthorized credential recovery compared with session-only secret injection.

Content

Scanner excerpt · SKILL.md (reported line 107)May include surrounding context.

bash
mkdir -p ~/.config/nano-banana2
cat > ~/.config/nano-banana2/.env << 'EOF'
X_API_KEY=你的x-api-key
EOF
chmod 600 ~/.config/nano-banana2/.env

Credential Access

High
Category
Privilege Escalation
Confidence
96% confidence
Finding

The same .env persistence pattern is reinforced by permission-setting instructions, normalizing long-lived local storage of the API key. Restrictive permissions help, but they do not remove the underlying risk of plaintext credential retention and later access by malware, backups, or operator error.

Content

Scanner excerpt · SKILL.md (reported line 110)May include surrounding context.

cat > ~/.config/nano-banana2/.env << 'EOF' X_API_KEY=你的x-api-key EOF chmod 600 ~/.config/nano-banana2/.env

text

### 后续自动加载

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 237)May include surrounding context.

md
- `SKILL.md`

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/generate.sh (reported line 59)May include surrounding context.

sh
exit 1
fi

if [[ -z "${X_API_KEY:-}" && "$use_local_key" == "true" && -f "$HOME/.config/nano-banana2/.env" ]]; then
  require_cmd "grep"
  require_cmd "tail"
  require_cmd "cut"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/generate.sh (reported line 65)May include surrounding context.

sh
exit 1
fi

if [[ -z "${X_API_KEY:-}" && "$use_local_key" == "true" && -f "$HOME/.config/nano-banana2/.env" ]]; then
  require_cmd "grep"
  require_cmd "tail"
  require_cmd "cut"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/generate.sh (reported line 70)May include surrounding context.

sh
exit 1
fi

if [[ -z "${X_API_KEY:-}" && "$use_local_key" == "true" && -f "$HOME/.config/nano-banana2/.env" ]]; then
  require_cmd "grep"
  require_cmd "tail"
  require_cmd "cut"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/generate.sh (reported line 64)May include surrounding context.

sh
require_cmd "tail"
  require_cmd "cut"
  require_cmd "tr"
  # Safely read key-value from .env without executing file content.
  X_API_KEY=$(grep -E '^X_API_KEY=' "$HOME/.config/nano-banana2/.env" | tail -n 1 | cut -d'=' -f2- | tr -d '\r')
fi

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

Scanner excerpt · scripts/generate.sh (reported line 92)May include surrounding context.

sh
payload=$(python3 -c "import json,sys; print(json.dumps({'urls': json.loads(sys.argv[1]), 'prompt': sys.argv[2], 'aspectRatio': sys.argv[3], 'imageSize': sys.argv[4]}, ensure_ascii=False))" "$urls_json" "$prompt" "$ratio" "$size")

# 带超时调用,只执行一次
response=$(curl -s -m "$TIMEOUT" --location "$API_URL" \
  --header 'Content-Type: application/json' \
  --header "x-api-key: $X_API_KEY" \
  --data "$payload" 2>&1)

Credential Access

High
Category
Privilege Escalation
Confidence
80% confidence
Finding

The script persists a sensitive API key in plaintext at $HOME/.config/nano-banana2/.env. Even though permissions are tightened afterward, local compromise, overly permissive backups/sync tools, accidental disclosure, or reading by other processes running as the same user could expose the credential and allow unauthorized use of the external image-generation API.

Content

Scanner excerpt · scripts/set_key.sh (reported line 25)May include surrounding context.

sh
fi

CONF_DIR="$HOME/.config/nano-banana2"
CONF_FILE="$CONF_DIR/.env"

mkdir -p "$CONF_DIR"
cat > "$CONF_FILE" <<EOF

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill declares shell-capable behavior but does not define any explicit tool scope such as allowed-tools or permissions. That increases the blast radius if the skill is invoked in a broader agent environment, because shell access plus file and network operations could be used beyond the narrowly intended image-generation workflow.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The manifest description is written entirely in Chinese and defines usage behavior in that language without indicating language choice or user opt-in. This can violate language/locale policy where skills should not implicitly force a specific language unless the constraint is documented and justified.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
93% confidence
Finding

The skill is explicitly designed to transmit user prompts, optional image URLs, and an API key to an external third-party endpoint. This is expected functionality, but it is still a real data egress boundary and can expose sensitive prompts, user-provided URLs, or billing-bearing credentials if invoked without clear consent and minimization.

Content

Scanner excerpt · SKILL.md (reported line 42)May include surrounding context.

md
- **单轮对话只允许调用 imgEditNB2 一次,绝不多次调用**
- **绝对禁止:不要因为结果慢就杀死进程重新发起请求**
- **这个 API 生成时间较长(可能需要5-10分钟),请耐心等待结果返回,不要中断或重试**
- 设置超时:curl 命令必须带 `-m 600`(10分钟超时),超时后报告失败,不要重试
- 禁止自动循环重试;任何重试都必须先向用户说明成本风险并获得明确同意。
- 同一组参数在同一轮对话中不得重复提交。

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The trigger phrases are broad enough to match common requests like '帮我生成一张图', which can cause the skill to activate unexpectedly. In a skill that performs network calls and may consume paid API credits, unintended invocation creates both privacy and cost risk.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
93% confidence
Finding

This finding reflects the same persistence behavior in duplicated analyzer output: durable local storage of API credentials in user configuration files. In the context of a networked skill with shell capability, persistence materially increases post-session exposure and recovery risk.

Content

Scanner excerpt · SKILL.md (reported line 106)May include surrounding context.

首次配置(只需一次)

bash
mkdir -p ~/.config/nano-banana2
cat > ~/.config/nano-banana2/.env << 'EOF'
X_API_KEY=你的x-api-key
EOF

Session Persistence

Medium
Category
Rogue Agent
Confidence
93% confidence
Finding

This finding reflects the same persistence behavior in duplicated analyzer output: durable local storage of API credentials in user configuration files. In the context of a networked skill with shell capability, persistence materially increases post-session exposure and recovery risk.

Content

Scanner excerpt · SKILL.md (reported line 106)May include surrounding context.

首次配置(只需一次)

bash
mkdir -p ~/.config/nano-banana2
cat > ~/.config/nano-banana2/.env << 'EOF'
X_API_KEY=你的x-api-key
EOF

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · SKILL.md (reported line 110)May include surrounding context.

cat > ~/.config/nano-banana2/.env << 'EOF' X_API_KEY=你的x-api-key EOF chmod 600 ~/.config/nano-banana2/.env

text

### 后续自动加载

External Transmission

Medium
Category
Data Exfiltration
Confidence
94% confidence
Finding

The command template demonstrates direct transmission of prompts and the x-api-key to an external endpoint via curl. Even though this is core functionality, embedding raw command patterns for secret-bearing requests increases the chance of leakage through shell history, process inspection, copied logs, or user misuse.

Content

Scanner excerpt · SKILL.md (reported line 216)May include surrounding context.

md
export X_API_KEY='你的x-api-key'

# 3) 仅提示词生成
curl --location 'https://agent.mathmind.cn/minimalist/api/imgEditNB2' \
--header 'Content-Type: application/json' \
--header "x-api-key: $X_API_KEY" \
--data '{"urls":[],"prompt":"一只猫咪在玩耍","aspectRatio":"auto","imageSize":"1K"}'

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The guide instructs callers to send prompts and optional image URLs to a third-party endpoint but does not warn that this data leaves the local system and is transmitted to an external service. In an agent skill, users may provide sensitive prompts or private image URLs, so lack of disclosure increases the risk of unintended data exposure and privacy violations.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
93% confidence
Finding

The cURL example demonstrates sending user-controlled prompt data and optional image references to an external host, confirming external transmission behavior. In this skill's context, that becomes security-relevant because the documentation does not pair the example with consent, minimization, or sensitivity warnings, so implementers may forward private user content without adequate notice.

Content

Scanner excerpt · references/api-guide.md (reported line 38)May include surrounding context.

  • 2K
  • 4K

cURL Example

bash
curl --location 'https://agent.mathmind.cn/minimalist/api/imgEditNB2' \

External Transmission

Medium
Category
Data Exfiltration
Confidence
90% confidence
Finding

This code performs an outbound network request containing the prompt, URLs, and API key to a remote endpoint. In a skill context, external transmission is security-relevant because prompts or referenced images may contain sensitive business, personal, or internal information, and the destination service gains access to that content.

Content

Scanner excerpt · scripts/generate.sh (reported line 92)May include surrounding context.

sh
payload=$(python3 -c "import json,sys; print(json.dumps({'urls': json.loads(sys.argv[1]), 'prompt': sys.argv[2], 'aspectRatio': sys.argv[3], 'imageSize': sys.argv[4]}, ensure_ascii=False))" "$urls_json" "$prompt" "$ratio" "$size")

# 带超时调用,只执行一次
response=$(curl -s -m "$TIMEOUT" --location "$API_URL" \
  --header 'Content-Type: application/json' \
  --header "x-api-key: $X_API_KEY" \
  --data "$payload" 2>&1)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The script transmits user-supplied prompts and optional image URLs to a third-party remote API, but the script itself provides no explicit disclosure, consent prompt, or warning at execution time. This can expose sensitive prompts, internal URLs, or private image references to an external service without the operator fully realizing what data leaves the system.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/set_key.sh (reported line 31)May include surrounding context.

sh
cat > "$CONF_FILE" <<EOF
X_API_KEY=$KEY
EOF
chmod 600 "$CONF_FILE"

echo "x-api-key saved to $CONF_FILE"

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

The only natural-language example prompt is written in Chinese, which can implicitly steer users toward a specific language/locale without any opt-in or explanation. For a general API guide, this can conflict with language-neutral policy expectations unless the regional scope is explicitly documented.

Content

No source excerpt is available for this finding.