T09 · Insecure Skill Coding Practices
- Location
scripts/communicator.js:89- Finding
OS Command Injection Through Unsanitized Session Key
- Content
View full analysis
- Remediation
View remediation
{ const child = spawn( 'openclaw', ['sessions', 'cleanup', '--active-key', sessionKey, '--enforce'], { shell: false } ); let stdout = ''; let stderr = ''; child.stdout.on('data', data => { stdout += data; }); child.stderr.on('data', data => { stderr += data; }); child.on('error', reject); child.on('close', code => { if (code === 0) { resolve({ stdout, stderr, code }); } else { reject(new Error(`openclaw exited with code ${code}: ${stderr}`)); } }); }); } ``` 2. **Validate the session key before execution.** Enforce the documented subagent-session structure and a conservative character allowlist. Reject unexpected whitespace, quotes, shell metacharacters, control characters, and excessive lengths. Validation should reflect the authoritative OpenClaw session-key specification rather than accepting arbitrary strings. 3. **Verify provenance.** Where possible, accept only session keys returned directly by trusted `sessions_list` or `sessions_spawn` operations. Do not use values copied from untrusted messages or external input without independent verification. 4. **Apply least privilege.** Run the OpenClaw process under a dedicated, restricted operating-system account with minimal filesystem and credential access. Do not grant unnecessary administrative privileges. 5. **Correct the documentation.** Replace the unsafe `exec` examples in `SKILL.md:151-153` and `SKILL.md: ...[truncated 331 chars]
