Back to skill

Security audit

Key Swap

Security checks for vulnerabilities and agentic risk

Overview

This skill has a legitimate key-rotation purpose, but it handles a powerful API token through broad triggers and an unsafe shell-style invocation that needs review before installation.

Install only if you trust the publisher and need this exact OpenClaw profile rotation. Use it only after an explicit request, avoid pasting tokens into ambiguous conversations, and prefer a version that reads the token from protected input, validates the full token format, avoids printing token fragments, and passes arguments without shell interpolation.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:11
Finding
Shell Command Injection Through Unquoted User-Controlled Token## Vulnerability Details **File Location**: `SKILL.md`, lines 11-15 **Vulnerability Type**: Shell command injection **Risk Level**: High **Vulnerable Code**: ```markdown 2. Run the rotation script: ```bash bash /opt/homebrew/lib/node_modules/openclaw/skills/keyswap/scripts/keyswap.sh <token> ``` ``` ### Technical Analysis The instructions direct the agent to place a user-provided token directly into a shell command, but they do not require shell-safe argument passing or quoting. The only stated validation rule is that the value must begin with `sk-ant-`. A value can satisfy that prefix requirement while containing shell metacharacters such as semicolons, command substitutions, redirections, or pipelines. If the agent constructs and executes the documented command as a shell string, the shell interprets those metacharacters before `keyswap.sh` receives and validates its arguments. Consequently, the prefix check inside the script cannot prevent command injection that occurs during shell parsing. ### Attack Path 1. An attacker provides a purported token beginning with the required `sk-ant-` prefix but followed by shell syntax. 2. The agent substitutes the value into the documented command without shell-safe quoting. 3. The command runner invokes a shell to interpret the constructed command. 4. The shell processes the injected metacharacters before starting `keyswap.sh`. 5. The injected command executes with the same operating-system privileges as the agent or OpenClaw process. 6. Any subsequent validation performed by `keyswap.sh` is ineffective against the command that has already executed. ### Impact Assessment Successful exploitation could provide arbitrary command execution under the account running the agent. The attacker could read or modify files accessible to that account, steal credentials such as OpenClaw authentication profiles, alter agent configuration, execute additional local programs, or di ...[truncated 152 chars]
Remediation
## Remediation Suggestions - Do not interpolate the token into a shell command string. - Invoke the script through a structured process-execution API that passes each argument as a separate argument vector element without shell interpretation. - Prefer reading the token from protected standard input or a dedicated file descriptor rather than placing it on the command line. - If shell execution is unavoidable, apply robust shell escaping generated by a trusted mechanism rather than manually adding quotation marks. - Validate the complete token format and length, not only its prefix. Reject control characters, whitespace, shell metacharacters, and unexpected character classes. - Update the Skill instructions to explicitly prohibit constructing a shell command through raw string substitution.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/keyswap.sh:13
Finding
API Token Exposure Through Process Arguments and Error Output## Vulnerability Details **File Location**: `scripts/keyswap.sh`, lines 13-19; invocation documented in `SKILL.md`, lines 11-15 **Vulnerability Type**: Sensitive credential exposure **Risk Level**: Medium **Vulnerable Code**: ```bash [[ $# -ne 1 ]] && usage TOKEN="$1" # Validate token format if [[ ! "$TOKEN" =~ ^sk-ant- ]]; then echo "ERROR: Token must start with 'sk-ant-'. Got: ${TOKEN:0:10}..." exit 1 fi ``` The corresponding invocation places the secret directly in the process argument list: ```bash bash /opt/homebrew/lib/node_modules/openclaw/skills/keyswap/scripts/keyswap.sh <token> ``` ### Technical Analysis The API token is accepted as a command-line argument. Command-line arguments may be observable through process inspection facilities, command auditing, shell history, automation telemetry, debugging output, or agent execution logs. Although the duration of exposure may be short, the script later waits for five seconds, potentially extending the lifetime of the process containing the token in its original argument list. When validation fails, the script also writes the first ten characters of the supplied value to standard output. This output may be returned to the user or retained in operational logs. Even partial secret disclosure is unnecessary and weakens redaction guarantees, particularly where token prefixes or identifying fragments are considered sensitive. ### Attack Path 1. A legitimate operator supplies a Claude API token using the documented invocation. 2. The token is included in the operating-system process argument list. 3. A local observer, process-monitoring component, command logger, or automation platform records or reads that argument list. 4. The observer obtains the token and can reuse it wherever the credential is accepted. 5. Alternatively, an invalid or malformed credential causes the script to print its first ten characters, and that fragment is ret ...[truncated 610 chars]
Remediation
## Remediation Suggestions - Read the token from protected standard input or another non-command-line channel. - If interactive use is supported, use silent input such as `read -r -s TOKEN` and avoid terminal echo. - For automated use, pass the token through a securely permissioned file descriptor or temporary credential file with restrictive permissions and immediate deletion. - Do not print any portion of a supplied credential. Replace the current error with a generic validation message. - Ensure shell tracing is disabled and configure the surrounding agent and automation platform to redact secrets from logs. - Clear the shell variable when it is no longer needed where practical, while recognizing that this does not remove copies already captured in process arguments or logs. - Rotate any token suspected of having appeared in command histories, process telemetry, or retained logs.
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (1)

Vague Triggers

Medium
Confidence
93% confidence
Finding
The trigger list includes broad phrases like "new key" and "rotate key," which can appear in ordinary conversation and may cause this privileged credential-rotation skill to activate unintentionally. Because the skill updates API tokens and restarts a gateway, accidental invocation could overwrite valid secrets, disrupt service, or cause sensitive token handling in the wrong context.

Static analysis

No suspicious patterns detected.