T09 · Insecure Skill Coding Practices
Error
- Location
- final_integration_test.sh:17
- Finding
- API Key Disclosure Through Shell Tracing and Command-Line Expansion<![CDATA[ ## Vulnerability Details **File Location**: `final_integration_test.sh:17-36` **Vulnerability Type**: Secret exposure through shell tracing and process arguments **Risk Level**: High ### Vulnerable Code ```bash set -x # 1) Sync plugin to remote echo "Step 1: Syncing plugin to remote host..." tar --exclude='.git' --exclude='node_modules' --exclude='pnpm-lock.yaml' -czf - . | \ ssh -o ConnectTimeout=30 "$REMOTE_HOST" "rm -rf $REMOTE_PLUGIN_DIR 2>/dev/null; mkdir -p $REMOTE_PLUGIN_DIR && tar -xzf - -C $REMOTE_PLUGIN_DIR" # 2) Remove existing plugin and install echo "Step 2: Installing plugin..." ssh -o ConnectTimeout=120 "$REMOTE_HOST" "set -x ; rm -rf /home/node/.openclaw/extensions/nano-gpt 2>/dev/null; rm ~/.openclaw/agents/main/sessions/* ;cd '$REMOTE_PLUGIN_DIR'; openclaw plugins install '$REMOTE_PLUGIN_DIR' " # 3) Start gateway echo "Step 3: Starting gateway..." ssh -o ConnectTimeout=30 "$REMOTE_HOST" "nohup openclaw gateway run > /tmp/gateway.log 2>&1 & sleep 5; openclaw gateway health" # 4) Onboard with NanoGPT echo "Step 4: Onboarding with NanoGPT..." ssh -o ConnectTimeout=30 "$REMOTE_HOST" "openclaw onboard --non-interactive --accept-risk --nano-gpt-api-key \"$NANOGPT_API_KEY\" --flow quickstart --skip-health" ``` ### Technical Analysis The script enables `set -x` before expanding `NANOGPT_API_KEY` into an SSH command. Shell tracing prints expanded commands to standard error, so the real API key can be written to interactive terminal output, CI logs, build logs, or other log collectors. The key is also supplied as a command-line argument to `openclaw onboard`. Depending on process visibility and timing, command arguments may be observable through process-inspection interfaces on the remote system. The remote installation command independently enables `set -x`, demonstrating that traced execution is part of the test workflow. Although transmitting the key to NanoGPT is necessary for the provider, exposing it through diagnostic tracing ...[truncated 874 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Disable tracing before any operation that reads or expands credentials: ```bash set +x openclaw onboard ... ``` 2. Do not pass API keys directly as command-line arguments. Prefer protected standard input, a file descriptor, or a secret-store integration supported by OpenClaw. 3. If an environment variable is unavoidable, pass it through a narrowly scoped protected environment and ensure the receiving command does not echo it. 4. Configure CI systems to mask the key and prevent secret-bearing logs from being retained as artifacts. 5. Rotate any key that may already have appeared in integration-test logs. 6. Add a regression test that executes the script with a sentinel secret and verifies that the sentinel does not appear in captured output. ]]>
