T09 · Insecure Skill Coding Practices
Warning
- Location
- README.md:24
- Finding
- Credential file may be created with overly permissive filesystem permissions<![CDATA[ ## Vulnerability Details **File Location**: `README.md:24-30` **Vulnerability Type**: Insecure credential storage permissions **Risk Level**: Medium ### Vulnerable Code ```bash mkdir -p ~/.clawdbot/credentials/prowlarr cat > ~/.clawdbot/credentials/prowlarr/config.json << 'EOF' { "url": "https://prowlarr.example.com", "apiKey": "your-api-key-here" } EOF ``` The resulting credential is read by `scripts/prowlarr-api.sh:7-11`: ```bash CONFIG_FILE="${PROWLARR_CONFIG:-$HOME/.clawdbot/credentials/prowlarr/config.json}" # Load config if [[ -f "$CONFIG_FILE" ]]; then PROWLARR_URL=$(jq -r '.url // empty' "$CONFIG_FILE") PROWLARR_API_KEY=$(jq -r '.apiKey // empty' "$CONFIG_FILE") ``` ### Technical Analysis The setup instructions create a directory and API-key file without assigning restrictive permissions. Their effective permissions therefore depend on the user's current `umask`. With a common `umask` of `022`, the directory may be created as mode `0755` and the configuration file as mode `0644`, making the API key readable by other local users. Accessing a Prowlarr credential is necessary for the Skill's declared functionality. However, granting potential read access to users other than the credential owner is not necessary and violates least-access principles for secret storage. The script also accepts a custom path through `PROWLARR_CONFIG` but does not verify the file's owner, permissions, or type before reading it. This increases exposure where the configured file is stored in an unsafe location, although exploitation still depends on local filesystem access and permissions. ### Attack Path 1. A user follows the documented setup commands while operating under a permissive `umask`. 2. The Prowlarr configuration is created with permissions that permit another local account or process to read it. 3. An attacker with local access enumerates or uses the documented path at `~/.clawdbot/credentials/prowlarr/config.json`. 4. The attacker r ...[truncated 891 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions Create the credential directory and file with owner-only permissions: ```bash install -d -m 700 "$HOME/.clawdbot/credentials/prowlarr" install -m 600 /dev/null "$HOME/.clawdbot/credentials/prowlarr/config.json" cat > "$HOME/.clawdbot/credentials/prowlarr/config.json" <<'EOF' { "url": "https://prowlarr.example.com", "apiKey": "your-api-key-here" } EOF ``` Alternatively, set a restrictive process mask before creating either object: ```bash umask 077 mkdir -p "$HOME/.clawdbot/credentials/prowlarr" ``` Additional hardening should include: 1. In the script, reject credential files that are symbolic links or are not regular files. 2. Verify that the file is owned by the current user. 3. Warn or fail if group or other permission bits are present. 4. Document that environment variables can also leak through process environments, diagnostics, or child processes and should not be treated as universally safer. 5. Rotate the Prowlarr API key if the file was previously stored with permissive permissions. ]]>
