T09 · Insecure Skill Coding Practices
- Location
- scripts/run.py:250
- Finding
- API Credential Exposure Through Command-Line Arguments## Vulnerability Details **File Location**: `scripts/run.py:250-257` **Additional Location**: `SKILL.md:68-72` **Vulnerability Type**: Sensitive credential exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```python def main(): parser = argparse.ArgumentParser(description="药物靶点筛选 — 对候选靶点进行优先级排序") parser.add_argument("--input", required=True) parser.add_argument("--output", default="") parser.add_argument("--input-type", default="auto", choices=["auto", *sorted(SUPPORTED_FILE_TYPES)]) parser.add_argument("--sheet", default=""); parser.add_argument("--encoding", default="utf-8") parser.add_argument("--save-prepared", action="store_true") parser.add_argument("--appkey", required=True, help="内部医疗大模型鉴权key(必填)") args = parser.parse_args() ``` The documented invocation also explicitly places the secret on the command line: ```bash python3 scripts/run.py --input input.json --output output.json --appkey YOUR_KEY ``` ### Technical Analysis The API bearer token is accepted as a normal command-line argument. Command-line arguments may be exposed through shell history, process inspection utilities, operating-system process interfaces, CI/CD logs, job schedulers, crash reports, and orchestration telemetry. Although the token is subsequently transmitted over HTTPS, transport encryption does not protect it from local disclosure before the request is made. The issue is particularly relevant on shared systems or where process metadata and execution logs are accessible to users other than the process owner. ### Attack Path 1. A user follows the documented command and supplies a valid API key with `--appkey`. 2. The complete command is recorded in shell history, automation logs, or process metadata. 3. A local user, administrator, monitoring service, or log reader accesses that information. 4. The exposed token is extracted. 5. The token is reused to make ...[truncated 619 chars]
- Remediation
- ## Remediation Suggestions - Remove the `--appkey` command-line option for production use. - Read the credential from a protected environment variable or an operating-system secret store. - Prefer a secret manager or inherited file descriptor for automated deployments. - If a credential file is supported, require restrictive permissions and avoid printing its contents or path unnecessarily. - Update `SKILL.md` so examples do not encourage users to place secrets directly in commands. - Ensure application errors, request diagnostics, and CI logs never include authorization headers. - Rotate any token that may already have appeared in shell histories or execution logs.
