T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/setup.py:167
- Finding
- LLM API Key Exposed Through Command-Line Arguments and Plaintext Configuration<![CDATA[ ## Vulnerability Details **File Location**: `scripts/setup.py:167-181`; related insecure usage is documented in `SKILL.md:103-105` and `SKILL.md:111-118` **Vulnerability Type**: Plaintext secret handling and command-line credential exposure **Risk Level**: Medium ### Vulnerable Code ```python # Configure LLM if provided if llm_api_key and llm_base_url and llm_model: config["thinking"]["enhanced"]["use_llm_analysis"] = True config["thinking"]["intent"]["use_llm"] = True config["thinking"]["intent"]["llm_api_key"] = llm_api_key config["thinking"]["intent"]["llm_base_url"] = llm_base_url config["thinking"]["intent"]["llm_model"] = llm_model print(f"[OK] LLM configured / LLM 配置完成: {llm_model}") else: print(f"[INFO] LLM not configured / LLM 未配置 (using local mode)") # Write config config_path = base_path / "config.yaml" try: import yaml with open(config_path, "w", encoding="utf-8") as f: yaml.dump(config, f, default_flow_style=False, allow_unicode=True) ``` The setup interface accepts the credential directly as a command-line argument: ```python parser.add_argument("--api-key", default=None, help="LLM API key / LLM API 密钥") ``` The documented invocation encourages this behavior: ```bash python ~/.openclaw/skills/neural-memory-cn/scripts/setup.py \ --api-key "your-key" \ --base-url "https://openrouter.ai/api/v1" \ --model "openai/gpt-3.5-turbo" ``` ### Technical Analysis Command-line arguments are commonly visible in shell history and may temporarily be visible through operating-system process inspection facilities. Passing a live API key through `--api-key` therefore exposes it beyond the intended process. The setup script subsequently stores the key directly in `config.yaml`. The file is opened using the process's ordinary default permissions, without explicitly enforcing owner-only access. Its effective permissions consequently depend on the user's `umask`, existing file permissions, directo ...[truncated 1499 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove or deprecate the `--api-key` command-line option. 2. Accept credentials through a protected environment variable or an interactive prompt using `getpass.getpass()`. 3. Prefer storing a secret reference rather than the secret itself, using an operating-system keychain or dedicated secret manager. 4. If file-based storage is unavoidable: - Create the file atomically. - Enforce owner-only permissions such as `0600`. - Verify and correct permissions on existing files before writing. - Ensure the parent directory is accessible only to the owning user. 5. Remove examples that embed API keys in command lines or YAML files. 6. Warn users that rotating the key is necessary if it has previously appeared in shell history. 7. Redact credentials from errors, logs, diagnostics, and configuration displays. ]]>
