T09 · Insecure Skill Coding Practices
- Location
SKILL.md:139- Finding
API Key Exposure Through Conversation and Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 139, 169, and 198
Vulnerability Type: Insecure secret handling
Risk Level: MediumVulnerable Code Snippets
SKILL.md:139:text 1. --api-key parameter (provided by the user in the conversation)SKILL.md:169:text A: Pass it through the `--api-key` parameter, or set the `GEMINI_API_KEY` environment variable. The script reports an error if neither is available.SKILL.md:198:text - It may also be passed through the `--api-key` parameterThe snippets above are English translations of the original Chinese instructions, preserving their security-relevant meaning.
Technical Analysis
The skill explicitly permits users to provide a Gemini API key in the conversation and allows the agent to pass that secret through the
--api-keycommand-line argument.Supplying an API key in a conversation can persist the credential in chat transcripts, telemetry, agent traces, or tool-call logs. Passing it as a command-line argument may additionally expose it through process listings, shell history, command auditing, diagnostic output, or execution logs.
This creates a credential-disclosure risk even though the document also recommends environment-variable storage. No executable implementation exists in the audited project, so actual redaction behavior or secure secret handling cannot be verified.
Attack Path
- The skill asks or permits the user to provide a Gemini API key in the conversation.
- The conversation platform, agent trace, or associated telemetry records the plaintext credential.
- Alternatively, the agent inserts the key into a command using
--api-key. - The command becomes visible in process metadata, shell history, audit records, or tool-execution logs.
- A party with access to any exposed record obtains the credential.
- The exposed key is reused to make unauthorized Gemini API requests ...[truncated 575 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove all instructions permitting users to submit API keys in conversations.
- Remove support and documentation for the
--api-keycommand-line option. - Require
GEMINI_API_KEYto be supplied through a protected runtime environment or platform secret manager. - Ensure agent responses, tool calls, exception messages, and diagnostic logs redact credentials.
- Avoid echoing environment variables or printing complete request headers and configuration objects.
- Use a dedicated, least-privileged API key restricted to the required API, project, quota, and permitted origin where supported.
- Add startup validation that reports only whether the secret is configured, never its value.
- Document immediate key revocation and rotation procedures for suspected disclosure.
- Once the referenced implementation is added, test it for secret leakage through process listings, shell history, logs, errors, and generated artifacts.
