T09 · Insecure Skill Coding Practices
- Location
SKILL.md:33- Finding
Arbitrary Shell Execution Through Sourced Credential File
- Content
View full analysis
"$_H" \ && curl -s "https://www.virustotal.com/api/v3{PATH}" -H@"$_H" \ && rm -f "$_H" ``` ### Technical Analysis The shell dot command does not parse the target as a passive environment-data file. It executes every command in that file in the context of the current shell. Consequently, a credential file containing additional shell statements can execute arbitrary commands with the privileges of the agent or user invoking the Skill. The `VIRUSTOTAL_SECRETS_FILE` environment variable also allows the source path to be redirected. If an attacker can influence that variable, modify the expected credentials file, or cause the agent to use an untrusted workspace configuration, the attacker can turn a routine VirusTotal query into local command execution. Executing an entire shell file exceeds the minimum privilege necessary for the declared functionality, which only requires retrieving one API-key value. ### Attack Path 1. An attacker modifies `~/.openclaw/secrets/virustotal.env` or causes `VIRUSTOTAL_SECRETS_FILE` to reference an attacker-controlled file. 2. The malicious file contains a valid-looking API-key assignment followed by arbitrary shell commands. 3. A user asks the agent to perform a VirusTotal operation. 4. The agent follows the documented request pattern and sources the file. 5. The attacker's commands execute before the VirusTotal API request, using the invoking agent's operating-system privi ...[truncated 808 chars]- Remediation
View remediation
` and never evaluates its contents as shell syntax. - Reject duplicate keys, command substitutions, shell metacharacters, additional directives, and unexpected lines. - Resolve the credential path against an approved location rather than accepting an unrestricted environment-provided path. - Verify that the credential file is a regular file, is owned by the current user, is not a symbolic link, and has restrictive permissions such as `0600`. - Pass the parsed key directly to the HTTP client while ensuring that command tracing and diagnostic logs cannot expose it. ]]>
