T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:52
- Finding
- Unsafe Plaintext API Key Persistence and Shell Sourcing<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 52–60; additional system-wide storage recommendation at line 182 **Vulnerability Type**: Plaintext credential storage, unsafe file overwrite, and execution of configuration as shell code **Risk Level**: Medium ### Vulnerable Code ```bash Or add to your shell profile (`~/.bashrc` or `~/.zshrc`): ```bash export EXA_API_KEY="your_exa_api_key_here" ``` Or create a `.env` file in your workspace: ```bash echo "EXA_API_KEY=your_exa_api_key_here" > ~/.openclaw/workspace/.env source ~/.openclaw/workspace/.env ``` ``` The troubleshooting section also recommends broader credential storage: ```text - If using systemd/systemctl, set the key in the service file or `/etc/environment` ``` ### Technical Analysis The documented setup persists the Exa API key in predictable plaintext locations without establishing restrictive permissions. The redirection operator also unconditionally truncates the existing `.env` file and follows symbolic links. Consequently, following the instructions can destroy existing workspace configuration or overwrite another user-writable file targeted through a malicious symlink. Using `source` interprets the entire `.env` file as shell code rather than reading only the expected `EXA_API_KEY` value. If another process or local user can modify or replace this file before it is sourced, arbitrary commands in the file execute with the privileges of the user performing setup. The recommendation to place the key in `/etc/environment` or a service file can expose it more broadly than required. The Skill only needs access to one environment variable while executing, so system-wide credential persistence exceeds the minimum privilege and exposure necessary for its declared web-search function. ### Attack Path 1. A local attacker obtains write access to the OpenClaw workspace or can replace `~/.openclaw/workspace/.env`. 2. The attacker creates a malicious `.env` file containing the ...[truncated 1458 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Prefer OpenClaw's scoped secret-injection mechanism documented in `README.md`, so the key is available only to this Skill at runtime. 2. Remove recommendations to store the key in `/etc/environment`, general shell profiles, or broadly readable service configuration. 3. Do not use `source` to load credential files. Parse only the expected variable as data and reject unexpected content. 4. If file-based storage is unavoidable: - Create a dedicated file with mode `0600`. - Ensure its parent directory is owned by the intended user and is not writable by untrusted users. - Refuse to overwrite an existing file. - Check that the path is a regular file rather than a symbolic link. - Verify file ownership before reading it. 5. Avoid embedding real credentials directly in shell commands because they may be retained in shell history. 6. Document API-key rotation and immediate revocation procedures for suspected exposure. ]]>
