T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/enterprise_detail.py:205
- Finding
- API Credential Exposure Through Command-Line Arguments and URL Query Parameters<![CDATA[ ## Vulnerability Details **File Locations**: - `SKILL.md:39-43` - `SKILL.md:87-90` - `scripts/enterprise_detail.py:10-13` - `scripts/enterprise_detail.py:205-216` **Vulnerability Type**: API credential exposure **Risk Level**: Medium ### Vulnerable Code and Documentation The Skill recommends passing the API key directly as a command-line argument: ```bash # Option 3: Pass it on the command line for each invocation python scripts/enterprise_detail.py --key YOUR_APP_KEY --keyword "Company Name" ``` The script also advertises and accepts this insecure configuration method: ```python API Key configuration, in descending priority: 1. Command-line argument: python enterprise_detail.py --key your_api_key --keyword CompanyName ``` ```python if args[i] == "--key" and i + 1 < len(args): cli_key = args[i + 1] i += 2 ``` The documentation additionally recommends a direct GET request that embeds the API credential and enterprise identifier in the URL: ```text GET https://japi.juhe.cn/enterprise/getDetailByName?key=YOUR_KEY&keyword=CompanyName ``` ### Technical Analysis Secrets supplied through command-line arguments can be exposed through: - Shell command history - Process listings and process-inspection interfaces - Job-control and process-monitoring tools - Terminal session recordings - Command logging, telemetry, and diagnostic systems - CI/CD logs or automation output Embedding the API key in a URL creates additional exposure because complete URLs may be retained in reverse-proxy logs, web-server access logs, browser history, monitoring platforms, network diagnostics, and error reports. The `keyword` parameter may contain a registration number or unified social-credit code and can consequently also enter those records. The actual runtime API call in `scripts/enterprise_detail.py` uses HTTPS and sends the key and keyword to the declared Juhe endpoint as form-encoded POST data: ```python params = {"key": api_key, "keyword": keywor ...[truncated 1985 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove support for the `--key` command-line option so credentials cannot be exposed through process arguments or shell history. 2. Remove the documented GET example containing `key=YOUR_KEY`. Do not place credentials in URLs or query strings. 3. Prefer the existing `JUHE_ENTERPRISE_DETAIL_KEY` environment variable for noninteractive execution. 4. For interactive use, accept the key through a non-echoing prompt such as Python's `getpass.getpass()`. 5. If `.env` support is retained: - Require restrictive file permissions, such as `chmod 600 scripts/.env`. - Ensure `.env` is excluded from version control. - Warn users not to place the file in shared or web-accessible directories. 6. Avoid printing, logging, or including the API key in exceptions and diagnostic output. 7. Update all help text, examples, and configuration instructions to remove command-line and URL-based secret handling. 8. Rotate any API key that may previously have been passed through command-line arguments or embedded in logged URLs. ]]>
