Back to skill

Security audit

Nano Banana 2 — Gemini Image Generation

Security checks for vulnerabilities and agentic risk

Overview

The skill appears to be for Gemini image generation, but its setup can expose your API key and its declared command permissions are broader than needed.

Install only if you are comfortable giving the skill access to a Gemini API key and sending prompts or source images to Google services. Do not run the documented echo commands for GEMINI_API_KEY; use a boolean presence check instead, and consider narrowing/removing the broad curl and unrestricted python3 permissions before use.

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

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:25
Finding
API Key Disclosed Through Verification and Troubleshooting Commands<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:25-29`; additional instances in `rules/setup.md:45-50`, `rules/setup.md:56-59`, and `rules/setup.md:88-91` **Vulnerability Type**: Credential exposure through terminal output **Risk Level**: High ### Vulnerable Code `SKILL.md:25-29`: ```markdown `GEMINI_API_KEY` must be set in the environment. Verify with: ```bash echo $GEMINI_API_KEY ``` ``` `rules/setup.md:45-50`: ```markdown ### Step 3: Verify ```bash echo $GEMINI_API_KEY ``` A non-empty string confirms the key is set. nano-banana-2 never prints the full key value in command output. ``` `rules/setup.md:56-59`: ```bash source ~/.zshrc echo $GEMINI_API_KEY ``` `rules/setup.md:88-91`: ```markdown Check for extra spaces or newline characters in the key. Inspect safely: ```bash python3 -c "import os; k=os.environ.get('GEMINI_API_KEY',''); print('len:', len(k), 'first8:', repr(k[:8]))" ``` ``` ### Technical Analysis The command `echo $GEMINI_API_KEY` prints the complete authentication secret to standard output. This output can be retained in agent transcripts, CI logs, terminal recordings, debugging systems, or other monitoring infrastructure. The behavior directly contradicts the nearby assertion that the Skill never prints the full key. The troubleshooting command discloses the first eight characters of the key. Although this is not the complete credential, exposing any secret prefix is unnecessary and can facilitate credential identification, correlation, or accidental leakage. This flaw is especially relevant in an AI Agent environment because command output may be copied into the model's context or persisted by the orchestration platform. ### Attack Path 1. A user or Agent follows the documented setup or troubleshooting workflow. 2. `GEMINI_API_KEY` is already present in the process environment. 3. The verification command expands and prints the full key, or the troubleshooting command prints its first eight characters. 4. The o ...[truncated 726 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Replace all secret-printing verification commands with a boolean check: ```bash if [ -n "${GEMINI_API_KEY:-}" ]; then echo "GEMINI_API_KEY is set" else echo "GEMINI_API_KEY is not set" fi ``` 2. For troubleshooting, report only non-sensitive metadata such as whether the variable exists and its length: ```bash python3 -c "import os; k=os.environ.get('GEMINI_API_KEY'); print('set:', bool(k), 'length:', len(k) if k else 0)" ``` 3. Do not print even a partial key prefix. Remove the conflicting recommendation from `rules/security.md` that permits displaying the first few characters. 4. Correct the inaccurate statement that the Skill never prints the full key. 5. Ensure logs and Agent transcripts apply automatic secret redaction as defense in depth. 6. If the documented commands have already been executed in a logged environment, remove the secret from retained logs where possible and rotate the affected API key. ]]>

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
SKILL.md:12
Finding
Overly Broad Bash Network and Code-Execution Permissions<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:12-16` **Vulnerability Type**: Violation of least privilege through unrestricted command patterns **Risk Level**: Medium ### Vulnerable Code ```yaml allowed-tools: - Bash(curl *) - Bash(python3 *) - Bash(mkdir *) - Bash(open .nano-banana/*) ``` ### Technical Analysis The Skill allows arbitrary arguments to `curl` and `python3`. These permissions exceed the minimum capabilities required by the declared image-generation workflow. The documented implementation uses Python's standard-library `urllib.request` to contact one fixed Google API endpoint; it does not use `curl`. Therefore, `Bash(curl *)` is unnecessary. Unrestricted `Bash(python3 *)` is also effectively a general-purpose local code-execution capability. Python can read or modify accessible files, inspect environment variables, start subprocesses, and communicate with arbitrary network destinations. The endpoint is hardcoded in the example scripts, which reduces risk in the documented path, but the tool declaration does not enforce that restriction. If an Agent is influenced by malicious contextual content or an adversarial prompt, these broad permissions could be repurposed beyond image generation. ### Attack Path 1. The Skill is loaded with unrestricted `curl` and Python command patterns enabled. 2. An attacker supplies a malicious prompt, project instruction, or other contextual content that influences the Agent's tool selection. 3. The Agent invokes `python3` to read local files or environment variables, or invokes `curl` with an attacker-controlled destination. 4. Sensitive local data is processed or transmitted outside the documented Google API workflow. 5. The attacker receives data accessible under the Agent process's operating-system permissions. This attack path depends on the surrounding Agent accepting malicious instructions; no instruction-hijacking payload was found in the audited Skill itself. ### Impact Assess ...[truncated 566 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove the unused `Bash(curl *)` permission. 2. Move the inline Python examples into a fixed, reviewed script shipped with the Skill. Permit only invocation of that specific script rather than arbitrary `python3` arguments. 3. Where the Skill platform supports it, constrain outbound network access to: ```text https://generativelanguage.googleapis.com/ ``` 4. Restrict filesystem access to user-selected source images and the `.nano-banana/` output directory. 5. Validate source-image paths, reject unsupported file types, and avoid accepting command fragments as path or prompt parameters. 6. Preserve the requirement that API calls occur only after an explicit user request and show the user which prompt or image will be uploaded. 7. If platform-level command restrictions cannot adequately constrain Python, implement the Gemini operation as a dedicated typed tool with fixed request construction, destination allowlisting, and explicit input fields. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Rogue AgentSelf-Modification, Session Persistence
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (6)

Credential Access

High
Category
Privilege Escalation
Content
**Project `.env` file:**

```bash
echo 'GEMINI_API_KEY=your-key-here' >> .env
echo ".env" >> .gitignore   # add immediately — never commit keys
source .env
```
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
**Project `.env` file:**

```bash
echo 'GEMINI_API_KEY=your-key-here' >> .env
echo ".env" >> .gitignore   # add immediately — never commit keys
source .env
```
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
echo 'GEMINI_API_KEY=your-key-here' >> .env
echo ".env" >> .gitignore   # add immediately — never commit keys
source .env
```
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Whitespace Padding

Medium
Category
Prompt Injection
Content
## API Reference

| Property             | Value                                                                                                     |
| -------------------- | --------------------------------------------------------------------------------------------------------- |
| Model                | `gemini-3.1-flash-image-preview`                                                                          |
| Endpoint             | `https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent` |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The search-grounded operation explicitly enables `googleSearch` with `webSearch` and `imageSearch`, which causes user prompts to be sent to external live search services. The skill metadata and workflow mention grounded generation but do not clearly warn that prompt contents may leave the local environment and be disclosed to third parties, creating a privacy and data-handling risk if users include sensitive project details, internal names, or personal data in prompts.

Session Persistence

Medium
Category
Rogue Agent
Content
### Step 1: Obtain a Key

1. Go to https://aistudio.google.com/app/apikey
2. Create a new project key or copy an existing one
3. Confirm the key has access to `gemini-3.1-flash-image-preview`

### Step 2: Set the Environment Variable
Confidence
60% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Static analysis

No suspicious patterns detected.