T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/hinge_android.py:244
- Finding
- Gemini API Key Exposed Through Process Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/hinge_android.py`, lines 244-252 **Vulnerability Type**: Secret exposure through command-line arguments **Risk Level**: Medium ### Vulnerable Code ```python result = subprocess.run( ["curl", "-s", "-X", "POST", f"{GEMINI_URL}?key={GEMINI_API_KEY}", "-H", "Content-Type: application/json", "-d", f"@{tmp_path}"], capture_output=True, text=True, timeout=45 ) os.unlink(tmp_path) ``` ### Technical Analysis The Gemini API key is inserted into the request URL and passed directly as a `curl` command-line argument. Command-line arguments may be visible to other local users or processes through process inspection interfaces and may also be collected by process-monitoring, diagnostic, auditing, or crash-reporting tools. Placing a secret in a URL additionally increases the chance of accidental retention in HTTP diagnostics or tooling logs. Although the request is sent over HTTPS, transport encryption does not protect the key from local command-line observation. ### Attack Path 1. The Skill starts a session and invokes `curl` to analyze a profile. 2. The API key appears in the running process arguments as part of `?key=...`. 3. A local process or user with permission to inspect process metadata reads the `curl` command line while the request is active, or obtains it from monitoring logs. 4. The observer extracts the Gemini API key. 5. The exposed key is reused to issue unauthorized Gemini API requests until it is revoked or restricted. ### Impact Assessment Successful exploitation discloses the Gemini API credential. An attacker could consume the associated API quota, incur usage costs where billing is enabled, disrupt legitimate requests through quota exhaustion, or access other Gemini API operations permitted by the key. This issue does not directly grant host or emulator control. Its scope is limited to the services and projects authorized by the exposed API key. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions - Replace the external `curl` invocation with an HTTPS client library so the credential never appears in a child process argument list. - Send the API key using the authentication mechanism recommended by the Gemini API, preferably a request header rather than a query parameter where supported. - Apply API-key restrictions, including API scope, project, quota, and source restrictions. - Ensure exception-safe cleanup of the temporary request file by using a `finally` block. - Rotate the existing API key if the Skill has already run on a shared or monitored system. - Redact secrets from application logs, error output, and HTTP diagnostics. ]]>
