T09 · Insecure Skill Coding Practices
- Location
scripts/generate-daily-report.js:154- Finding
Arbitrary Shell Command Injection Through Report Content and Recipient Configuration
- Content
View full analysis
10) { const cmd = `openclaw message send --channel openclaw-weixin --account d72d5b576646-im-bot --target "${notifyUser}" --message "${section.replace(/"/g, '\\"')}"`; try { execSync(cmd, { stdio: 'pipe' }); ``` ### Technical Analysis The function constructs a shell command by interpolating two untrusted values: - `notifyUser`, loaded from `~/.openclaw/hotspot/config.json`. - `section`, derived from Markdown containing externally retrieved RSS titles and descriptions. Only double quotation marks in `section` are escaped. This does not prevent shell evaluation inside double-quoted strings. Shell constructs such as command substitution with `$(...)` or backticks remain active. `notifyUser` is not escaped or validated at all. The resulting string is passed to `execSync`, which invokes a shell. Consequently, malicious report content or configuration data can inject commands that execute with the privileges of the user running the report generator. ### Attack Path 1. An attacker gains control of content returned by an RSS source, compromises an upstream feed, or causes a malicious title or description to appear in a feed. 2. The malicious field contains shell syntax such as `$(attacker_command)`. 3. `scripts/fetch-hotspots.js` stores the field without removing shell metacharacters. 4. The report generator incorporates the field into the Markdown report. 5. A user or scheduled process invokes: ```bash node scripts/generate- ...[truncated 977 chars]- Remediation
View remediation
