T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/config.sh:4
- Finding
- Plaintext SSH Credentials Stored with Unsafe Permissions and Exposed by Configuration Display<![CDATA[ ## Vulnerability Details **File Location**: `scripts/config.sh:4-14, 28-30, 62-65` **Vulnerability Type**: Plaintext credential storage and disclosure **Risk Level**: High ### Vulnerable Code ```bash CONFIG_DIR="${HOME}/.config/openclaw" CONFIG_FILE="${CONFIG_DIR}/cross-agent.conf" # Ensure the configuration directory exists mkdir -p "$CONFIG_DIR" show_config() { echo "📋 Current configuration:" if [ -f "$CONFIG_FILE" ]; then cat "$CONFIG_FILE" else echo " (No configuration)" fi } # ... --default-pass) echo "default_pass=$2" >> "$CONFIG_FILE" echo "✅ Default password set: ***" shift 2 ;; # ... if [ -f "$CONFIG_FILE" ]; then sort -u "$CONFIG_FILE" > "${CONFIG_FILE}.tmp" mv "${CONFIG_FILE}.tmp" "$CONFIG_FILE" fi ``` ### Technical Analysis The script writes the SSH password directly to `~/.config/openclaw/cross-agent.conf` without setting a restrictive `umask` or explicitly applying secure permissions to the directory and file. With a common `022` umask, the directory may be created as `0755` and the configuration file as `0644`, allowing other local users to read the stored password. The deduplication operation creates a second plaintext file, `${CONFIG_FILE}.tmp`, using the process's default permissions and then replaces the original configuration with that file. This can undo manually hardened permissions on the original file. The `show_config` function prints the complete configuration with `cat`, including every `default_pass` entry. Although password output is masked while setting the value, invoking `config --show` or completing a configuration operation can expose the actual password in terminal output, captured logs, or calling-process output. ### Attack Path 1. A user runs `config --default-pass` or saves credentials through the interactive wizard. 2. The password is written in plaintext to `~/.config/openclaw/cross-agent.conf`. 3. The file or its temporary replacement is c ...[truncated 802 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Set `umask 077` before creating any credential-bearing directory or file. - Create the configuration directory with `mkdir -p -m 700 "$CONFIG_DIR"`. - Create and maintain the configuration file with mode `0600`. - Apply mode `0600` to temporary files and use `mktemp` in the protected directory. - Preserve or explicitly restore restrictive permissions after replacing the configuration file. - Never print `default_pass`; redact it when displaying configuration. - Prefer SSH public-key authentication or a platform credential manager instead of persistent plaintext passwords. - Validate that `$2` exists before processing options that require values. - Consider separating non-sensitive defaults from credentials so ordinary configuration display cannot expose secrets. ]]>
