T09 · Insecure Skill Coding Practices
- Location
scripts/fastmail.py:164- Finding
Unsanitized Email Content Enables Terminal Output Injection
- Content
View full analysis
") print(f" To: {to}") if cc: print(f" CC: {cc}") print(f" Date: {e['receivedAt']}") print(f" Status: {'UNREAD' if unread else 'read'}") print(f" {'─' * 60}") body_text = "" for part in e.get("textBody", []): val = e.get("bodyValues", {}).get(part["partId"], {}) if val.get("value"): body_text += val["value"] if not body_text: for part in e.get("htmlBody", []): val = e.get("bodyValues", {}).get(part["partId"], {}) if val.get("value"): body_text += val["value"] print(body_text[:5000] if body_text else " (no body)") ``` Additional affected output path: ```python subj = e.get("subject", "(no subject)") print(f" {flag} {dt} | {fr:30s} | {subj}") print(f" {e['preview'][:120]}") print(f" id: {e['id']}") print() ``` ### Technical Analysis Email subjects, sender names, sender addresses, previews, and message bodies are controlled by external email senders. The script prints these values directly to the terminal without removing or escaping terminal control characters. A malicious message can contain ANSI or OSC escape sequences. Depending on the terminal emulator, these sequences can: - Change colors or overwrite visible terminal content. - Hide or forge status messages and command output. - Render deceptive terminal hyperlinks. - Change terminal titles. - Attempt clipboard manipulation through supported OSC sequences. - Mislead a human or an AI agent that consumes captured terminal output. Truncating the body by character count does not mitigate the issue because a functional escape sequence can fit within a few bytes. This flaw does not, by itself, execute shell ...[truncated 1321 chars]- Remediation
View remediation
