T09 · Insecure Skill Coding Practices
- Location
scripts/audit_output.py:62- Finding
Untrusted Terminal Control Sequences Are Printed Without Sanitization
- Content
View full analysis
Vulnerability Details
File Location:
scripts/audit_output.py, lines 62–68 and 135–139
Vulnerability Type: T09: Insecure Skill Coding Practices
Risk Level: MediumVulnerable Code
python def decisive_lines(text: str): out = [] for line in text.splitlines(): low = line.lower() if any(re.search(p, low) for p in SUCCESS_PATTERNS + FAIL_PATTERNS + PARTIAL_PATTERNS + WARNING_PATTERNS): out.append(line) return out[:12]python lines = decisive_lines(text) if lines: for line in lines: print(f'- {line}') else: print('- No decisive lines found; inspect the full output manually.')Technical Analysis
The auditor treats captured command output as untrusted input but prints selected lines directly to the terminal. The original lines are preserved without removing or escaping ANSI escape sequences, OSC sequences, C0/C1 control characters, or other terminal directives.
An attacker-controlled command can include a recognized pattern such as
successfully,error:, orwarnin a line containing terminal control sequences. The line will passdecisive_lines()and subsequently be written unchanged to the operator's terminal.Depending on terminal capabilities and configuration, malicious sequences could alter colors, move the cursor, erase or overwrite displayed text, create deceptive hyperlinks, change a terminal title, or otherwise spoof the visible audit result. This does not establish arbitrary operating-system command execution by itself, but it undermines the integrity of the security-relevant output.
Attack Path
- An attacker influences the output of a command, build process, log source, package, or remote service being audited.
- The attacker emits a line containing a recognized classification keyword and crafted terminal control sequences.
- The operator saves that output to a file or pipes it to
audit_output.py. decisive_lines()selects the malicious li ...[truncated 936 chars]
- Remediation
View remediation
Remediation Suggestions
- Sanitize every untrusted line before printing it to an interactive terminal.
- Remove or visibly escape ANSI, OSC, C0, and C1 control sequences, including the ESC character and non-printable control bytes.
- Preserve ordinary newline and tab handling only when explicitly required.
- Consider rendering control characters in an unambiguous form such as
\x1b,\x07, or Unicode control pictures. - Provide a raw-output mode only as an explicit opt-in, accompanied by a warning that the content may contain terminal control sequences.
- Add regression tests containing cursor movement, screen clearing, OSC hyperlinks, terminal-title changes, carriage returns, backspaces, and mixed recognized keywords.
- Keep the computed verdict and recommendation separate from untrusted evidence and clearly delimit quoted evidence so it cannot visually impersonate trusted output.
