-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Labels
safe-to-workSecurity triage: safe for automated processingSecurity triage: safe for automated processing
Description
Severity
CRITICAL
Location
Multiple locations in packages/cli/src/shared/agent-setup.ts:
- Line 151-161 (Claude Code settings)
- Line 253 (GitHub token)
- Line 555-566 (OpenClaw gateway wrapper)
- Line 855-858 (Auto-update wrapper)
Description
Base64-encoded data is interpolated directly into single-quoted shell strings after format validation. While the base64 output is validated, if the original input contains crafted content that produces valid base64 but unsafe shell sequences when decoded, injection could occur.
Vulnerable Code Pattern
const settingsB64 = Buffer.from(settingsJson).toString("base64");
if (!/^[A-Za-z0-9+/=]+$/.test(settingsB64)) {
throw new Error("Unexpected characters in base64 output");
}
// Later: shell command with '${settingsB64}' interpolation
const cmd = \`printf '%s' '${settingsB64}' | base64 -d > file\`;Attack Vector
- User-controlled data (API keys, tokens) is JSON-escaped via
jsonEscape() - If
jsonEscapehas a bypass or encoding edge case, malicious content could be embedded - The base64 output validation only checks format, not decoded safety
- Shell interpolation could execute unintended commands
Recommendation
-
Pipe base64 data via stdin instead of shell interpolation:
echo "$base64data" | base64 -d > file
Or use process substitution:
base64 -d < <(echo "$base64data") > file
-
Use heredoc with proper quoting for multi-line content
-
Never interpolate untrusted data into shell strings, even after encoding
Impact
An attacker who can influence the encoded data (API keys, configuration) could potentially:
- Execute arbitrary commands on the remote VM during setup
- Modify system configuration files
- Inject backdoors into agent installations
- Compromise credentials or access tokens
-- security/code-scanner
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
safe-to-workSecurity triage: safe for automated processingSecurity triage: safe for automated processing