Back to skill

Security audit

Nano Banana 2 Image Gen(基于API易代理站)

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent image-generation skill that uses a disclosed third-party API, with privacy and API-key handling cautions but no evidence of hidden malware or persistence.

Install only if you are comfortable sending prompts and selected source images to APIYI's remote service. Use APIYI_API_KEY rather than passing keys on the command line, avoid sensitive images or confidential prompt text, and treat generated output paths as local file writes controlled by the command arguments.

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

Warning
Location
scripts/generate_image.py:323
Finding
API Credential Exposure Through Command-Line Arguments## Vulnerability Details **File Location**: `SKILL.md:217-222`, `scripts/generate_image.py:323`, `scripts/generate_image.js:270-274` **Vulnerability Type**: API credential exposure through process arguments and shell history **Risk Level**: Medium The Skill documents and implements an optional `-k` / `--api-key` argument that allows users to place an API credential directly on the command line. ### Vulnerable Code `SKILL.md:217-222`: ```bash **Command-line argument method (temporary):** ```bash python scripts/generate_image.py -p "一只猫" -k "your-api-key-here" ``` ``` `scripts/generate_image.py:323`: ```python parser.add_argument("--api-key", "-k", default=None, help="API密钥(覆盖环境变量)") ``` `scripts/generate_image.js:270-274`: ```javascript if (a === '-k' || a === '--api-key') { args.apiKey = requireValue(i, a); i++; continue; } ``` ### Technical Analysis Command-line arguments are not an appropriate channel for sensitive credentials. Depending on the operating system and its access controls, command arguments may be exposed through: - Shell history files. - Process inspection utilities and process metadata. - Terminal logging or session recording. - Diagnostic and monitoring software. - Automation logs that record invoked commands. The code does not print the API key or include it in its sanitized request-payload log. Nevertheless, accepting the credential as a process argument exposes it before and during program execution. The documentation increases the likelihood of exposure by explicitly recommending an invocation containing the secret. The scripts also support the safer `APIYI_API_KEY` environment variable. Consequently, command-line credential handling is not necessary for the Skill's declared image-generation and image-editing functionality and exceeds the minimum credential interface required. ### Attack Path 1. A user follows the documented example and invokes the sc ...[truncated 1087 chars]
Remediation
## Remediation Suggestions 1. Remove the `-k` / `--api-key` option from both the Python and Node.js implementations. 2. Remove the command-line credential example from `SKILL.md` and from both scripts' help text. 3. Continue accepting the credential through `APIYI_API_KEY`, or integrate with an operating-system credential manager or protected secret store. 4. If interactive use is required, read the key from a non-echoing prompt rather than from command arguments. 5. Ensure diagnostic output, exception handling, and request logging never include the `Authorization` header. 6. Advise users who previously used the documented command-line option to: - Rotate the affected API key. - Remove relevant entries from shell history where feasible. - Review terminal, CI/CD, and process-monitoring logs for retained credentials. 7. Apply service-side quota limits, key scoping, expiration, and usage alerts to reduce the impact of future credential disclosure.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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 (26)

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

Critical
Category
Data Flow
Content
print(f"输出请求参数: {json.dumps(payload_log, indent=2, ensure_ascii=False)}")
    print(f"image generation in progress...")
    try:
        response = requests.post(url, headers=headers, json=payload, timeout=400)
        response.raise_for_status()

        data = response.json()
Confidence
90% confidence
Finding
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
This skill says it does not require external internet access, yet it clearly sends data over HTTPS to api.apiyi.com and reportedly logs prompts and request configuration. That is a meaningful behavior gap because sensitive user text and input images may be transmitted and exposed in logs without an adequate user-facing warning.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
This skill says it does not require external internet access, yet it clearly sends data over HTTPS to api.apiyi.com and reportedly logs prompts and request configuration. That is a meaningful behavior gap because sensitive user text and input images may be transmitted and exposed in logs without an adequate user-facing warning.

Missing User Warnings

High
Confidence
98% confidence
Finding
The skill omits a clear user-facing warning that prompts and input images are sent to an external API service. In an image generation/editing context, prompts and source images often contain sensitive personal, confidential, or regulated information, so hidden transmission materially raises privacy and compliance risk.

Ae1

High
Category
analysis-evasion
Content
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Lp3

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding
The skill instructs the agent to use environment variables and make outbound network requests, but it does not declare any explicit tool scope or permissions. That mismatch weakens governance and review, making it easier for a skill to access secrets or external services without clear user or platform visibility.

External Transmission

Medium
Category
Data Exfiltration
Content
---
name: nano-banana-2-image-gen
description: 图片生成技能,当用户需要生成图片、视觉信息图、创建图像、编辑/修改/调整已有图片时使用此技能。基于中国的API易代理站(https://api.apiyi.com/)的NanoBanana2模型的图片生成服务,无需访问外网。支持14种宽高比的图片比例(`1:1`、`16:9`、`9:16`、`4:3`、`3:4`、`3:2`、`2:3`、`5:4`、`4:5`、`1:4`、`4:1`、`1:8`、`8:1`、`21:9`等)和3种分辨率(1K、2K、4K),支持文生图和图生图编辑。基于谷歌的NanoBanana2模型(快速模型),使用API易国内代理服务访问。
---

# 图片生成与编辑
Confidence
87% confidence
Finding
The document explicitly references an external endpoint, confirming that data leaves the local environment. External transmission is not always unsafe, but here it becomes security-relevant because the skill handles user prompts, optional input images, and API credentials while lacking strong disclosure and permission scoping.

Vague Triggers

Medium
Confidence
94% confidence
Finding
The activation condition is broad enough to trigger on many image-related requests, increasing the chance that users are routed into a remote third-party image workflow unnecessarily. In context, that matters because the skill forwards prompts and possibly images externally, so over-triggering increases accidental data exposure.

Ssd 3

Medium
Confidence
96% confidence
Finding
The instruction to preserve and forward the user's full raw input directly as the downstream prompt encourages unnecessary disclosure of everything the user typed, including secrets, personal data, or unrelated context. Because the destination is an external service, this increases privacy risk and makes accidental sensitive-data exfiltration more likely.

Natural-Language Policy Violations

Medium
Confidence
97% confidence
Finding
This file contains all primary natural-language instructions, examples, and CLI help in Chinese, including the header comments and later runtime messages. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly justified, which is not present here.

External Transmission

Medium
Category
Data Exfiltration
Content
const apiKey = getApiKey(args.apiKey);
  const url =
    'https://api.apiyi.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent';

  const headers = {
    Authorization: `Bearer ${apiKey}`,
Confidence
93% confidence
Finding
The script transmits user prompts, API credentials, and optionally local image contents to a third-party proxy service at api.apiyi.com. In this skill's context, that is the core function, but it still creates a real data-exposure boundary: sensitive prompts or local images may leave the host, and use of a domestic proxy increases trust and privacy considerations versus a direct first-party API.

Natural-Language Policy Violations

Medium
Confidence
87% confidence
Finding
The file's user-facing documentation and CLI descriptions are written only in Chinese, with no indication that users can choose another language or that the locale restriction is intentional and justified. This creates a language-policy issue because the skill experience is effectively constrained to a single language without opt-in.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The script sends user prompts and optional local input images to a remote third-party API endpoint, including potentially sensitive image contents, without an explicit consent or privacy warning at runtime. In the skill context, users may reasonably assume this is a local capability because it is presented as a convenient domestic proxy service, which increases the risk of unintentional data disclosure.

External Transmission

Medium
Category
Data Exfiltration
Content
api_key = get_api_key(api_key)
    url = (
        "https://api.apiyi.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent"
    )

    headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
print(f"输出请求参数: {json.dumps(payload_log, indent=2, ensure_ascii=False)}")
    print(f"image generation in progress...")
    try:
        response = requests.post(url, headers=headers, json=payload, timeout=400)
        response.raise_for_status()

        data = response.json()
Confidence
80% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Intent-Code Divergence

Low
Confidence
91% confidence
Finding
Manifest 描述称该技能基于“NanoBanana2模型”,而 L008 又写成“基于谷歌的Gemini 3.1 Flash模型实现图片生成技能”。如果这是同一模型的别名需要明确说明,否则文档在技能实际意图和所用模型上存在主动冲突。

Intent-Code Divergence

Low
Confidence
92% confidence
Finding
L039 指导先检查 `APIYI_API_KEY` 环境变量是否已设置,给人的含义是通过环境变量提供;但 L186 和 L207 又声明也可通过命令行参数 `--api-key` 提供。文档没有保持一致的主叙述,容易误导执行者对允许输入敏感凭证的方式产生错误预期。

Intent-Code Divergence

Low
Confidence
94% confidence
Finding
L152 写明未传 `-r/--resolution` 时“由 API 侧决定”,但 L182 又声明“默认:2K”。这会让技能调用者对实际行为产生相反理解,属于文档层面的意图与实现说明不一致。

Natural-Language Policy Violations

Low
Confidence
89% confidence
Finding
This markdown file is entirely written in Chinese and does not indicate that the skill is intentionally limited to Chinese-speaking users or offer any alternative language/locale option. Under the policy rule, forcing a specific language without user opt-in can be a natural-language policy violation.

Static analysis

No suspicious patterns detected.