T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/generate_auth_token.py:27
- Finding
- API Credentials Exposed Through Command-Line Arguments and Standard Output## Vulnerability Details **File Location**: `scripts/generate_auth_token.py`, lines 27-28 and 38-42 **Vulnerability Type**: Sensitive credential exposure **Risk Level**: Medium ### Vulnerable Code ```python credentials = f"{app_key}:{app_secret}" access_token = base64.b64encode(credentials.encode()).decode() return access_token ``` ```python app_key = sys.argv[1] app_secret = sys.argv[2] token = generate_access_token(app_key, app_secret) print(f"Access Token: {token}") print(f"\nUse in Authorization header as: Basic {token}") ``` The insecure invocation is also explicitly recommended in `SKILL.md`, line 19: ```bash python scripts/generate_auth_token.py YOUR_APP_KEY YOUR_APP_SECRET ``` ### Technical Analysis The script accepts an API secret through a command-line argument. Depending on the execution environment, command-line arguments may be exposed through shell history, process inspection, command auditing, Agent transcripts, or CI/CD logs. It then combines the application key and secret as `app_key:app_secret`, applies Base64 encoding, and prints the resulting HTTP Basic credential to standard output. Base64 provides no confidentiality and can be trivially decoded. Anyone who obtains the printed token can recover the original credentials or directly reuse the token. In an Agent environment, standard output may be returned to the caller and retained in conversation or execution logs. Printing the credential is not required for the Skill’s declared video-scoring functionality because the API client can construct and use the Authorization header internally. The related logic in `scripts/tomoviee_video_scoring_client.py`, lines 17-25, is not independently classified as a vulnerability: constructing an HTTP Basic credential in memory and sending it over HTTPS to the fixed API endpoint is necessary for the declared API operation, and that client does not print the token. ### Attack Path 1. A user follows the documented command and supplies a real appli ...[truncated 1140 chars]
- Remediation
- ## Remediation Suggestions 1. Remove all printing of authentication tokens and raw credentials: ```python print(f"Access Token: {token}") print(f"\nUse in Authorization header as: Basic {token}") ``` 2. Do not accept secrets through command-line arguments. Read the secret through a non-echoing prompt: ```python from getpass import getpass app_key = input("Application key: ") app_secret = getpass("Application secret: ") ``` 3. For automated environments, retrieve credentials from an approved secret manager or protected environment variables. Ensure environment access and log redaction policies are configured appropriately. 4. Construct the Authorization header only in memory and send it directly over verified HTTPS. Avoid returning or displaying the encoded token outside the API client. 5. Redact credentials and Authorization headers from exceptions, debug output, Agent traces, telemetry, and HTTP logging. 6. Update `SKILL.md` so it no longer instructs users to place secrets on the command line. Document secure credential provisioning instead. 7. Rotate any credentials previously used with this script if its stdout, command history, or Agent execution logs may have been retained or accessed by unauthorized parties.
