T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:58
- Finding
- Plaintext API Key Embedded in Generated Script<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:58-60` **Vulnerability Type**: Plaintext credential exposure **Risk Level**: Medium ### Vulnerable Code ```python API_KEY = "<API_KEY>" BASE = "https://api.bluente.com/api/20250924/blu_translate" HEADERS = {"Authorization": f"Bearer {API_KEY}"} ``` ### Technical Analysis The Skill instructs the agent to substitute the user's Bluente API key directly into a generated Python script. This leaves the bearer credential in plaintext source code. Depending on how the agent creates and executes the script, the credential may persist in the workspace, temporary files, backups, source-control history, agent transcripts, or tool logs. File permissions are not restricted, and the instructions do not require deletion of the generated script after execution. Sending the key to Bluente in an authorization header is necessary for the declared cloud translation function. Persistently embedding it in generated code is not necessary and exceeds minimum secure credential-handling requirements. ### Attack Path 1. A user provides a valid Bluente API key to the Skill. 2. The agent inserts the key into the generated Python script as `API_KEY = "..."`. 3. The script or its contents remain accessible through the workspace, logs, backups, source control, or agent execution history. 4. An attacker with access to one of those locations extracts the bearer token. 5. The attacker submits authenticated requests to Bluente using the compromised token. ### Impact Assessment Successful exploitation exposes the privileges granted to the Bluente API key. An attacker could consume translation services, incur usage against the victim's account, and potentially access other account-scoped API resources available to that credential. This issue does not grant local operating-system privilege escalation by itself. Its scope is limited primarily to the API permissions associated with the exposed key. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Pass the API key through a protected environment variable or standard input rather than embedding it in source code: ```python import os API_KEY = os.environ["BLUENTE_API_KEY"] HEADERS = {"Authorization": f"Bearer {API_KEY}"} ``` 2. Set the environment variable only for the lifetime of the process and avoid placing it in shell history. 3. Never print the key or include authorization headers in errors, debug output, or result summaries. 4. If a temporary script is required, create it with permissions restricted to the current user, such as mode `0600`. 5. Delete temporary scripts and clear temporary environment state immediately after execution. 6. Advise users to rotate any API key that may have been persisted or exposed. ]]>
