T09 · Insecure Skill Coding Practices
- Location
scripts/google_local.py:164- Finding
API Token Exposure Through Command-Line Arguments
- Content
View full analysis
str | None: token = clean_value(token_arg) or clean_value(os.environ.get("DATAIFY_API_TOKEN")) if not token: return None if not token.lower().startswith("bearer "): token = f"Bearer {token}" os.environ["DATAIFY_API_TOKEN"] = token return token ``` ### Technical Analysis The script permits a Dataify API token to be supplied directly through the `--token` command-line option. Command-line arguments are not an appropriate secret-transfer channel because they can be retained in shell history and, depending on the operating system and process isolation configuration, exposed through process-listing or process-inspection facilities. Although the script also supports the `DATAIFY_API_TOKEN` environment variable, the safer path does not eliminate the insecure command-line path. The documentation advises users not to paste tokens into chat, but the executable interface itself still accepts plaintext tokens as arguments. The token is legitimately transmitted over HTTPS to the documented Dataify endpoint. The vulnerability is therefore not unauthorized network exfiltration; it is the local exposure created before or during execution when the credential is placed in the process arguments. ### Attack Path 1. A user invokes the script using a command such as: ```bash python3 scripts/google_local.py --token DATAIFY_SECRET --q "coffee shops" ``` 2. The plaintext token becomes part of the command line. 3. The command may be saved in the user's shell history. On systems with permissive process inspection, it may also be visible w ...[truncated 880 chars]- Remediation
View remediation
str | None: token = clean_value(os.environ.get("DATAIFY_API_TOKEN")) if not token: return None return token if token.lower().startswith("bearer ") else f"Bearer {token}" ``` 5. Ensure documentation and examples exclusively demonstrate session-scoped environment-variable configuration and never include real credentials in commands, logs, diagnostic output, or error messages. 6. Recommend token rotation if a token has previously been supplied through the command line. ]]>
