T09 · Insecure Skill Coding Practices
- Location
SKILL.md:43- Finding
Local OpenRouter credentials may be exposed through command output
- Content
View full analysis
/dev/null || echo "No OPENROUTER_API_KEY in .env" cat ~/.openclaw/agents/main/agent/auth-profiles.json 2>/dev/null | rg -i openrouter || echo "No OpenRouter auth profile" ``` ### Technical Analysis The first command searches the local OpenClaw environment file and prints every complete line containing `OPENROUTER`. If the file contains an entry such as `OPENROUTER_API_KEY=`, the secret value is exposed directly in command output. The second command reads the entire OpenClaw authentication profile before filtering lines containing `openrouter`. Depending on the JSON layout, a matching line may include an API token or adjacent authentication data. Both operations exceed the minimum privilege required to determine whether OpenRouter authentication is configured: only a Boolean presence check is necessary. The Skill subsequently instructs the Agent to summarize the findings. Consequently, exposed credentials may enter the Agent's context, conversation transcripts, terminal logs, execution telemetry, or other retained records. The audited content does not instruct the Agent to send these values to an unrelated endpoint, so this is a local disclosure risk rather than confirmed credential exfiltration. ### Attack Path 1. A user invokes the Skill on a system with an OpenRouter key stored in `~/.openclaw/.env` or `~/.openclaw/agents/main/agent/auth-profiles.json`. 2. The Agent executes the prescribed provider and credential checks. 3. `grep` or `rg` returns a complete secret-bearing line rather than reporting only whether a credential exists. 4. The secret is incorporated into command output and potentially the Agent's context or summary. 5. An attacker or unauthorized party with access to conversation records, terminal logs, executio ...[truncated 701 chars]- Remediation
View remediation
/dev/null; then echo "OpenRouter API key is configured" else echo "OpenRouter API key is not configured" fi ``` For `auth-profiles.json`, parse the file and emit only a Boolean result or a non-sensitive provider name. Do not print the original matching JSON line. For example, use a structured JSON query tailored to the documented schema and ensure its output cannot include token fields. Additional hardening measures: 1. Explicitly instruct the Agent never to display, summarize, log, or retain API-key values. 2. Redact credential-like output before it reaches Agent context or telemetry. 3. Use secure interactive secret entry or protected standard input when onboarding, if supported, rather than exposing a token through expanded command-line arguments. 4. Restrict credential-file permissions to the owning user. 5. Rotate any key that has already appeared in a transcript, terminal log, or execution record. 6. Avoid suppressing every diagnostic with `2>/dev/null`; distinguish a missing file from permission, parsing, and configuration errors without revealing sensitive content. ]]>
