T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/vin_info.py:179
- Finding
- API Key Exposure Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/vin_info.py:9-13, 179-181, 225-229`; `SKILL.md:36-37` **Vulnerability Type**: Sensitive credential exposure through process arguments and shell history **Risk Level**: Medium ### Complete Code Snippets `scripts/vin_info.py:9-13`: ```python API Key 配置(任选其一,优先级从高到低): 1. 命令行参数:python vin_info.py --key your_api_key --vin LBV21AF05MSZ88595 2. 环境变量:export JUHE_VIN_CAR_DETAIL_KEY=your_api_key 3. 脚本同目录的 .env 文件:JUHE_VIN_CAR_DETAIL_KEY=your_api_key ``` `scripts/vin_info.py:179-181`: ```python if args[i] == "--key" and i + 1 < len(args): cli_key = args[i + 1] i += 2 ``` `scripts/vin_info.py:225-229`: ```python print("❌ 未找到 API Key,请通过以下方式之一配置:") print(" 1. 环境变量:export JUHE_VIN_CAR_DETAIL_KEY=your_api_key") print(" 2. .env 文件:在脚本目录创建 .env,写入 JUHE_VIN_CAR_DETAIL_KEY=your_api_key") print(" 3. 命令行参数:python vin_info.py --key your_api_key --vin LBV21AF05MSZ88595") print(f"\n申请 Key: {REGISTER_URL}") ``` `SKILL.md:36-37`: ```bash # 方式三:每次命令行传入 python scripts/vin_info.py --key 你的 AppKey --vin LBV21AF05MSZ88595 ``` ### Technical Analysis The script accepts the Juhe API key through the `--key` command-line argument, and the documentation explicitly recommends this as a supported configuration method. Command-line secrets can be exposed through: - Shell history files. - Process argument inspection while the command is running. - Process-monitoring and endpoint telemetry. - Debug logs generated by wrappers, schedulers, or automation systems. - Command transcripts and CI/CD job logs. Although the script also supports an environment variable and a local `.env` file, the command-line method creates unnecessary credential exposure and is not the least-risk configuration mechanism. The separate transmission of the API key and VIN to `https://apis.juhe.cn/carinfo/vinInfo` is consistent with the declared VIN lookup functionality. The reviewed code uses HTTPS and does not transmit these val ...[truncated 1644 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove support for the `--key` command-line argument so credentials cannot be placed in process arguments. 2. Remove all command-line key examples from `SKILL.md`, the module documentation, help output, and error messages. 3. Prefer the existing `JUHE_VIN_CAR_DETAIL_KEY` environment variable for noninteractive execution. 4. For interactive use, accept the credential through `getpass.getpass()` so it is not echoed or retained in shell history. 5. If `.env` support is retained: - Require or recommend restrictive permissions such as `0600`. - Ensure `.env` is excluded from version control. - Reject symlinks or unexpectedly permissive files where practical. 6. Avoid logging command lines, environment values, request bodies, or complete request URLs containing the key. 7. Rotate any API key previously supplied through command-line arguments if shell history, telemetry, or build logs may have retained it. ]]>
