T09 · Insecure Skill Coding Practices
- Location
scripts/generate_image.py:323- Finding
API Credential Exposure Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:217-222,scripts/generate_image.py:323,scripts/generate_image.js:270-274
Vulnerability Type: API credential exposure through process arguments and shell history
Risk Level: MediumThe Skill documents and implements an optional
-k/--api-keyargument that allows users to place an API credential directly on the command line.Vulnerable Code
SKILL.md:217-222:bash **Command-line argument method (temporary):** ```bash python scripts/generate_image.py -p "一只猫" -k "your-api-key-here"text `scripts/generate_image.py:323`: ```python parser.add_argument("--api-key", "-k", default=None, help="API密钥(覆盖环境变量)")scripts/generate_image.js:270-274:javascript if (a === '-k' || a === '--api-key') { args.apiKey = requireValue(i, a); i++; continue; }Technical Analysis
Command-line arguments are not an appropriate channel for sensitive credentials. Depending on the operating system and its access controls, command arguments may be exposed through:
- Shell history files.
- Process inspection utilities and process metadata.
- Terminal logging or session recording.
- Diagnostic and monitoring software.
- Automation logs that record invoked commands.
The code does not print the API key or include it in its sanitized request-payload log. Nevertheless, accepting the credential as a process argument exposes it before and during program execution. The documentation increases the likelihood of exposure by explicitly recommending an invocation containing the secret.
The scripts also support the safer
APIYI_API_KEYenvironment variable. Consequently, command-line credential handling is not necessary for the Skill's declared image-generation and image-editing functionality and exceeds the minimum credential interface required.Attack Path
- A user follows the documented example and invokes the sc ...[truncated 1087 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the
-k/--api-keyoption from both the Python and Node.js implementations. - Remove the command-line credential example from
SKILL.mdand from both scripts' help text. - Continue accepting the credential through
APIYI_API_KEY, or integrate with an operating-system credential manager or protected secret store. - If interactive use is required, read the key from a non-echoing prompt rather than from command arguments.
- Ensure diagnostic output, exception handling, and request logging never include the
Authorizationheader. - Advise users who previously used the documented command-line option to:
- Rotate the affected API key.
- Remove relevant entries from shell history where feasible.
- Review terminal, CI/CD, and process-monitoring logs for retained credentials.
- Apply service-side quota limits, key scoping, expiration, and usage alerts to reduce the impact of future credential disclosure.
- Remove the
