T09 · Insecure Skill Coding Practices
- Location
scripts/ultra-play.js:43- Finding
Shell Command Injection in the Ultra Player
- Content
View full analysis
${CACHE_FILE}`); } catch (e) {} } ``` ```js if (cached && cached.videoId) { console.log(`⚡ Cache hit: ${cached.videoId}`); const url = `${YOUTUBE_WATCH}${cached.videoId}`; fastExec(`openclaw browser open --targetUrl="${url}"`); console.log(`✅ Played in ${Date.now() - start}ms (CACHED)`); return { videoId: cached.videoId, cached: true, time: Date.now() - start }; } ``` ```js case 'direct': const videoId = args[1]; console.log(`🎵 Direct play: ${videoId}`); fastExec(`openclaw browser open --targetUrl="${YOUTUBE_WATCH}${videoId}"`); console.log(`✅ Playing!`); break; ``` The commands are executed by this wrapper: ```js function fastExec(cmd, ignoreError = true) { try { return execSync(cmd, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: 5000 }).trim(); } catch (e) { return ignoreError ? '' : e.message; } } ``` ### Technical Analysis `execSync()` receives a single command string, causing Node.js to invoke a system shell. User-controlled data is inserted directly into that command string. The `direct` command accepts `args[1]` as a video ID without validating its format. Because the value is placed inside a double-quoted shell argument, embedded quote characters, command substitutions, or other shell syntax can terminate or alter the intended argument. The cache-writing operation is also unsafe. Search queries become properties in the cache object and are serialized by `JSON.stringify()`. JSON serialization does not make the result safe for insertion into a single-quoted shell expression. A query containing a single quote can ...[truncated 1423 chars]- Remediation
View remediation
