T09 · Insecure Skill Coding Practices
- Location
src/cli.js:374- Finding
Unsanitized Attacker-Controlled Text Is Written to Interactive Terminals
- Content
View full analysis
80 ? '...' : '') : ''; lines.push(` ${color.dim(loc)}: "${preview}"`); if (match.suggestion) { lines.push(` ${color.green('→')} ${match.suggestion}`); } ``` The grouped suggestion formatter also renders attacker-controlled matched text without sanitization: ```js lines.push(` ${color.dim(truncate(s.text, 60))}`); ``` This operation occurs in the critical, important, and minor suggestion sections at lines 417, 427, and 437. The autofix command prints the complete transformed input directly: ```js console.log(formatSuggestions(result)); if (flags.autofix && result.autofix) { console.log(`\n${color.bold('── AUTO-FIXED TEXT ──────────────────────────────')}\n`); console.log(result.autofix.text); console.log(`\n${color.dim('════════════════════════════════════════════════')}`); } ``` ### Technical Analysis The CLI accepts potentially untrusted text from a file or standard input. Portions of that text, and in the autofix case nearly the entire resulting document, are passed to `console.log` without removing terminal control characters. Truncating a string with `substring` does not neutralize ANSI escape sequences, Operating System Command sequences, carriage returns, backspaces, or other control characters. When output is connected to an interactive terminal, the terminal emulator may interpret these sequences rather than display them as ordinary text. Depending on terminal configuration and supported features, crafted input may: - Clea ...[truncated 1769 chars]- Remediation
View remediation
