T09 · Insecure Skill Coding Practices
- Location
scripts/fetch_fund_data.py:295- Finding
API Key Exposure Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/fetch_fund_data.py:295; insecure usage is recommended inREADME.md:33-34andSKILL.md:16
Vulnerability Type: API key disclosure through process arguments, shell history, and operational telemetry
Risk Level: LowVulnerable Code
python parser.add_argument("--api-key", help="API密钥,如果不提供则从环境变量读取")The README explicitly recommends supplying the secret through this argument:
bash # 使用 --api-key(推荐) python scripts/fetch_fund_data.py --api-key "your-api-key" list --keyword 沪深300The Skill instructions similarly characterize command-line injection as a preferred method:
markdown 2. **优先安全注入**:优先通过 `--api-key` 参数或短期环境变量注入,避免写入长期共享配置Technical Analysis
Supplying an API key as a command-line argument places the plaintext credential in the process argument vector. Depending on the operating environment, it may consequently be exposed through:
- Shell history files
- Process-listing and monitoring tools
- OS audit records
- Terminal session recordings
- CI/CD job logs and orchestration telemetry
- Diagnostic or support bundles
This is especially problematic because the project documentation recommends
--api-keyas the preferred method. The implementation does not intentionally print the key, and the key is transmitted only to the fixed, documented HTTPS service. Nevertheless, command-line handling creates an avoidable local disclosure channel.Attack Path
- A user follows the documented recommendation and runs the script with
--api-key "secret-value". - The plaintext command is retained in shell history, process telemetry, audit records, or session logs.
- A local user, administrator, monitoring service, CI log reader, or other principal with access to those records retrieves the credential.
- The exposed key is reused against
https://www.cifangquant.com/api. - The attacker consumes the victim' ...[truncated 843 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the
--api-keyoption where compatibility permits, or mark it explicitly as unsafe for shared systems. - Stop recommending command-line secret injection in
README.mdandSKILL.md. - Prefer
CIFANG_API_KEYsupplied by a scoped secret manager or a short-lived, restricted process environment. - Offer interactive secret entry through Python's
getpass.getpass()when no environment-based secret is available. - If command-line compatibility must be retained, emit a warning explaining that the key may appear in shell history and process telemetry.
- Configure CI/CD systems to inject the key through their protected secret mechanisms and mask it from logs.
- Continue ensuring that exception messages, debug output, request logs, and diagnostic reports never contain the API key.
- Advise users to rotate the credential immediately if it has previously been supplied on a monitored or shared command line.
- Remove the
