T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/text_translate.py:65
- Finding
- Translation credentials exposed through command-line arguments<![CDATA[ ## Vulnerability Details **File Locations**: - `scripts/text_translate.py:65` - `scripts/image_translate.py:126-127` - `SKILL.md:51-55` - `SKILL.md:97-102` **Vulnerability Type**: Sensitive credentials passed through process command-line arguments **Risk Level**: Medium ### Vulnerable Code `scripts/text_translate.py:65`: ```python parser.add_argument("--api-key", required=True, help="Text translation key (TextTransKey)") ``` The source code uses a Chinese help string; its functional meaning is shown in English above. `scripts/image_translate.py:126-127`: ```python parser.add_argument("--img-key", required=True, help="ImgTransKey") parser.add_argument("--user-key", required=True, help="UserKey") ``` `SKILL.md:51-55` documents direct command-line use of the text translation credential: ```bash python scripts/text_translate.py \ --api-key YOUR_TEXT_TRANS_KEY \ --texts "你好世界" \ --source-language CHS \ --target-language ENG ``` `SKILL.md:97-102` documents direct command-line use of the image translation credentials: ```bash python scripts/image_translate.py \ --img-key YOUR_IMG_TRANS_KEY \ --user-key YOUR_USER_KEY \ --file /path/to/image.png \ --source-language JPN \ --target-language ENG ``` ### Technical Analysis The scripts require API credentials to be supplied as ordinary command-line arguments. Depending on the operating system and execution environment, command-line arguments may be exposed through: - Shell history files. - Process inspection interfaces and utilities. - CI/CD job output or retained workflow metadata. - Debugging, monitoring, telemetry, or endpoint-management software. - Wrapper scripts and orchestration logs. The text translation API key is transmitted directly to the documented HTTPS endpoint in the `X-API-Key` header. For image translation, the `UserKey` is used with the `ImgTransKey` and timestamp to create an MD5 request signature. Although the `UserKey` is not directly included in the outbound req ...[truncated 2089 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Stop requiring secrets as command-line arguments.** - Read credentials from protected environment variables such as `XIANGJI_TEXT_API_KEY`, `XIANGJI_IMG_KEY`, and `XIANGJI_USER_KEY`. - Alternatively, use an interactive password prompt implemented with `getpass.getpass()` so input is not echoed or included in process arguments. 2. **Support permission-restricted credential files where automation is required.** - Require restrictive file permissions, such as owner read/write only. - Reject or warn about credential files readable by other users. - Do not store secrets in the project directory or source-control repository. 3. **Retain command-line credential flags only as a deprecated compatibility mechanism, if necessary.** - Display a clear warning explaining that command-line secrets may be visible in process lists, history, and logs. - Prefer environment variables or secure secret stores whenever both mechanisms are available. 4. **Update every example in `SKILL.md`.** - Replace literal secret arguments with environment-variable or protected-input examples. - Explain the data sent to the external translation service and advise users not to translate confidential material unless the service's privacy and retention terms are acceptable. 5. **Harden operational usage.** - Inject secrets through the secret-management facilities of the relevant CI/CD or orchestration platform. - Mask credential values in logs. - Rotate the affected keys if they have already appeared in shell history, process captures, or build logs. - Apply account quotas and monitor for unexpected translation activity. ]]>
