T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/track_volume.py:292
- Finding
- Billing API Key Exposed Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:18-21`, `SKILL.md:37-43`, and `scripts/track_volume.py:292-296` **Vulnerability Type**: Command-line credential exposure **Risk Level**: Medium The documented and implemented interface requires the SkillPay API key to be supplied as a command-line argument. ### Vulnerable Code From `SKILL.md:18-21`: ```bash python scripts/track_volume.py --api-key YOUR_SKILLPAY_API_KEY --user-id YOUR_USER_ID ``` From `SKILL.md:37-43`: ```bash export SKILLPAY_API_KEY=your_api_key_here export SKILLPAY_USER_ID=your_user_id_here python scripts/track_volume.py --api-key $SKILLPAY_API_KEY --user-id $SKILLPAY_USER_ID ``` From `scripts/track_volume.py:292-296`: ```python parser.add_argument( "--api-key", required=True, help="skillpay.me API key for payment" ) ``` The supplied credential is subsequently placed in the authentication header used for SkillPay requests, as shown in `scripts/track_volume.py:28-32`: ```python headers = { "X-API-Key": self.api_key, "Content-Type": "application/json" } ``` ### Technical Analysis Command-line arguments are not an appropriate transport mechanism for secrets. Depending on the operating system and execution environment, process arguments can be observed through process inspection facilities while the program is running. They may also be retained in shell history, terminal logging, job-runner metadata, monitoring systems, or diagnostic output. Exporting the credential to an environment variable does not mitigate this issue when the variable is expanded into the command line, because the expanded secret still becomes part of the process argument list. The network transmission itself is disclosed by the Skill documentation and uses HTTPS. No evidence was found that the credential is sent to an undeclared host. The vulnerability is the local handling and exposure of the credential before it is used to authenticate to `skillpay.me`. ### Attack Path 1. A ...[truncated 1388 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Stop accepting API keys through ordinary command-line arguments. 2. Read `SKILLPAY_API_KEY` directly from the environment without expanding it into the command: ```python import os api_key = os.environ.get("SKILLPAY_API_KEY") if not api_key and not args.skip_payment: parser.error("SKILLPAY_API_KEY must be set when payment is enabled") ``` 3. Update the documented invocation to avoid placing the secret in the argument list: ```bash export SKILLPAY_API_KEY='your_api_key_here' python scripts/track_volume.py --user-id YOUR_USER_ID ``` 4. Prefer an operating-system credential store, protected configuration file, or secret-manager integration over long-lived environment variables where available. 5. Make credentials optional when `--skip-payment` is enabled, because billing authentication is unnecessary in that execution mode. 6. Ensure the API key is never included in exceptions, debug output, telemetry, command traces, or payment failure messages. 7. Use narrowly scoped and revocable API keys. Rotate any key previously supplied through the documented command-line pattern. 8. Consider accepting the key through a non-echoing interactive prompt when neither a secret manager nor an environment-based mechanism is available. ]]>
