T09 · Insecure Skill Coding Practices
- Location
oc-tool.html:1694- Finding
Shell command injection through imported Openclaw configuration
- Content
View full analysis
({ id: a.id, name: a.name || a.id, model: a.model || '', workspace: a.workspace || `~/.openclaw/workspace-${a.id}` })); ``` The imported values are later inserted directly into shell commands: ```javascript const agentBackupLines = agents.map(a => { const wsName = `workspace-${a.id}`; return [ ` mkdir -p ${wsName}`, ` for f in MEMORY.md SOUL.md IDENTITY.md AGENTS.md USER.md HEARTBEAT.md TOOLS.md; do`, ` [ -f ${a.workspace}/$f ] && cp ${a.workspace}/$f ${wsName}/$f`, ` done` ].join('\n'); }).join('\n\n'); const agentRestoreLines = agents.map(a => { return ` [ -d workspace-${a.id} ] && rsync -a workspace-${a.id}/ ${a.workspace}/`; }).join('\n'); const migrateWsLines = agents.map(a => { return `rsync -a ~/dotfiles/workspace-${a.id}/ ${a.workspace}/`; }).join('\n'); ``` ### Technical Analysis The `id` and `workspace` fields are read from a user-selected JSON file and retained without validation. They are subsequently interpolated into shell scripts without quoting or escaping. Although the application defines `sanitizePath`, it is not applied to these imported fields. Shell control operators, command substitutions, redirections, whitespace, and other metacharacters can therefore change the meaning of the generated script. This also contradicts the project documentation's assertion that all values flowing into generated shell commands are validated. ### Attack Path 1. An attacker prepares an `openclaw.json` file containing a malicious `id` or `workspace` value with embedded shell syntax. 2. The attacker persuades the victim to import that file into the assistant. 3. The assistant parses the file and generate ...[truncated 802 chars]- Remediation
View remediation
