T09 · Insecure Skill Coding Practices
- Location
scripts/setup.sh:16- Finding
Persistent Shell Command Injection Through Unsafely Generated Environment Configuration
- Content
View full analysis
"$OPENCLAW_ENV" << ENVEOF #!/bin/bash # === wsl-windows-bridge environment === # Auto-generated at $(date -u +%Y-%m-%dT%H:%M:%SZ) export WIN_BIN="\$HOME/.openclaw/bin" export PATH="\$WIN_BIN:\$PATH" export WIN_ROOT="$WIN_ROOT" export WIN_ANACONDA="$WIN_ROOT/app/anaconda" export WIN_SCRIPTS="$WIN_ROOT/app/scripts" export WIN_PROJECT="$WIN_ROOT/app/project" export WIN_PYTHON="$PYTHON_PATH" export WIN_PS="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe" export WIN_CMD="/mnt/c/Windows/System32/cmd.exe" winpath() { wslpath -w "\$1" 2>/dev/null; } wslpath_win() { wslpath -u "\$1" 2>/dev/null; } win-python-check() { if [ -f "$PYTHON_PATH" ]; then echo "OK: $PYTHON_PATH" "$PYTHON_PATH" --version else echo "ERROR: Python not found at $PYTHON_PATH" return 1 fi } win-ps-check() { if [ -f "/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powersh ...[truncated 3297 chars]- Remediation
View remediation
"$OPENCLAW_ENV" ``` 3. **Separate data from executable code.** Prefer storing path values in a non-executable configuration format. If a shell file is required, keep static function definitions in a trusted bundled file and place user-controlled values in a separately parsed data file. 4. **Avoid immediately sourcing generated files.** Perform verification using local variables or launch a clean subprocess only after validating the generated configuration. 5. **Restrict configuration permissions.** Create the file with a restrictive umask and verify that it is owned by the current user: ```bash umask 077 ``` 6. **Use atomic file generation.** Write to a securely created temporary file, validate its contents, set the required permissions, and atomically rename it to `~/.openclaw/env.windows.sh`. 7. **Add regression tests.** Test inputs containing quotes, command substitutions, newlines, semicolons, backticks, spaces, and Windows backslashes to confirm that they remain literal values and ...[truncated 32 chars]
