fix: sanitize untrusted terminal output to prevent escape sequence injection#240
Merged
felipefreitag merged 4 commits intomainfrom Apr 13, 2026
Merged
Conversation
…jection Add safeTerminalText utility that strips ANSI/VT control sequences and dangerous C0 control characters from untrusted data before rendering to the terminal in interactive mode. Applied to: - webhooks listen: sanitize type, resourceId, and detail from webhook payloads - table renderer: sanitize all cell contents in renderTable - All get commands: sanitize API-returned fields in interactive output - emails receiving listen: sanitize inbound email fields JSON/pipe mode is unaffected since it uses JSON.stringify which escapes control bytes. Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
Instead of wrapping every field individually in each command, sanitize the entire API response object once in runGet/runCreate/runList before passing it to onInteractive. This removes per-field safeTerminalText calls from 11 get commands and covers previously missed paths (automations, events, renderDnsRecordsTable, status indicator defaults). Also fixes regex literal lint warning and strips bare \r to prevent terminal line-overwrite attacks.
Contributor
There was a problem hiding this comment.
3 issues found across 14 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/commands/emails/receiving/get.ts">
<violation number="1">
P1: Untrusted email fields are written to interactive terminal output without sanitization, reintroducing escape-sequence injection risk.</violation>
</file>
<file name="src/commands/contact-properties/get.ts">
<violation number="1">
P1: Interactive CLI output logs untrusted API fields without `safeTerminalText`, reintroducing terminal escape-sequence injection risk.</violation>
</file>
<file name="src/commands/templates/get.ts">
<violation number="1">
P1: Interactive template fields are printed without `safeTerminalText`, reintroducing terminal escape-sequence injection risk.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
felipefreitag
approved these changes
Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by cubic
Sanitizes all untrusted interactive CLI output to block ANSI/OSC escape sequence injection (BU-650). Adds a shared
safeTerminalTexthelper and applies it across webhooks, emails receiving, tables, and all interactive get commands.safeTerminalTextto strip ANSI/VT and dangerous control chars (keeps tabs/newlines).webhooks listen(type/resourceId/detail), table renderer (all cells),emails receiving listen, and allgetcommands.Written for commit 5f04f30. Summary will update on new commits.