T09 · Insecure Skill Coding Practices
- Location
scripts/quick-music.js:48- Finding
Unsanitized Third-Party API Content Is Written to the Terminal
- Content
View full analysis
{ const name = (song.name || song.song || song.title || "未知").padEnd(28); const artist = song.artist || song.singer || song.author || "未知"; console.log(`${String(i + 1).padStart(4)} ${name} ${artist}`); }); ``` Additional affected output sinks appear at lines 94–105: ```js if (playUrl) { console.log(`🎶 ${title} - ${artist}`); console.log(`🔗 播放链接: ${playUrl}`); if (link) console.log(`🌐 详情页: ${link}`); if (cover) console.log(`🖼️ 封面: ${cover}`); if (lrc) console.log(`📝 歌词: ${lrc}`); console.log(); } else { console.log("未找到播放链接,返回数据:"); console.log(JSON.stringify(data, null, 2)); } ``` ### Technical Analysis Song names, artist names, URLs, and fallback response data originate from third-party API responses. These values are written directly to an interactive terminal without removing terminal control characters, ANSI escape sequences, or Operating System Command sequences. If either API is compromised or returns attacker-controlled metadata, a response can contain escape sequences that compatible terminal emulators interpret rather than display literally. Depending on terminal capabilities and configuration, this can: - Clear or rewrite portions of the visible terminal. - Forge trusted-looking status messages or conceal subsequent text. - Create misleading hyperlinks. - Change terminal presentation. - Attempt clipboard manipulation through mechanisms such as OSC 52. TLS reduces ordinary network tampering but does not protect against a compromised, malicious, or incorrectly configured API provider. The raw JSON fallback is also unsafe because JSON encoding does not provide terminal-specific escaping. ### Attack Path 1. An attacker gains control over data returned by one o ...[truncated 995 chars]- Remediation
View remediation
