T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/generate_auth_token.py:34
- Finding
- Reusable Basic Authentication Credential Exposed Through Command-Line Arguments and Standard Output<![CDATA[ ## Vulnerability Details **File Location**: `scripts/generate_auth_token.py:34-42` **Vulnerability Type**: Credential exposure through process arguments and standard output **Risk Level**: High ### Vulnerable Code ```python if __name__ == "__main__": if len(sys.argv) != 3: print("Usage: python generate_auth_token.py <app_key> <app_secret>") sys.exit(1) 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 token-generation operation at `scripts/generate_auth_token.py:27-29` is: ```python credentials = f"{app_key}:{app_secret}" access_token = base64.b64encode(credentials.encode()).decode() return access_token ``` The insecure invocation is also recommended in `SKILL.md:59-63`: ```bash python scripts/generate_auth_token.py YOUR_APP_KEY YOUR_APP_SECRET ``` ### Technical Analysis The helper accepts the application secret as a command-line argument and then prints a reusable Basic authentication credential to standard output. Command-line secrets can be exposed through shell history, process inspection facilities, execution telemetry, CI logs, terminal recordings, and Agent tool-call transcripts. The output introduces another disclosure channel because standard output may be captured by terminals, automation systems, logs, or an Agent and returned to its caller. Base64 provides no confidentiality. The printed value can be decoded directly to recover the original `app_key:app_secret` pair. Consequently, printing the token is effectively equivalent to printing the application secret. This behavior is not necessary for the Skill's declared video-generation functionality. The main client can construct the Authorization header internally and transmit it directly to the fixed HTTPS API endpoint without revealing the credential to the user or Agent output. The hel ...[truncated 1803 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the helper's token-printing behavior. Basic credentials must never be emitted to standard output, logs, exceptions, or Agent responses. 2. Remove or revise the Quick Start command in `SKILL.md` so users are not instructed to place secrets directly in command-line arguments. 3. Read credentials from a protected secret manager or narrowly scoped environment variables. For interactive use, obtain the secret with `getpass.getpass()` so it is not echoed or retained in ordinary shell history. 4. Construct the Authorization header only inside the API client immediately before the request. Do not expose the encoded value through a public helper or CLI output. 5. Prefer `requests.auth.HTTPBasicAuth` or an equivalent standard authentication facility instead of manually retaining a Base64 credential: ```python from requests.auth import HTTPBasicAuth response = requests.post( url, auth=HTTPBasicAuth(app_key, app_secret), headers={"Content-Type": "application/json", "X-App-Key": app_key}, json=payload, timeout=REQUEST_TIMEOUT, ) ``` 6. If environment variables are used, document that they must not be printed, committed, included in diagnostic bundles, or inherited by unnecessary child processes. 7. Redact `Authorization`, `app_secret`, and derived tokens from HTTP debugging, exception reporting, telemetry, and CI logs. 8. Prefer provider-issued short-lived, revocable tokens with minimum required permissions if the API supports them. 9. Rotate any credentials that have already been passed to this helper in logged, shared, CI, or Agent-controlled environments. ]]>
