Skip to content

Sanitize connection observability terminal escape sequences#1306

Draft
mscoutermarsh wants to merge 1 commit into
mainfrom
cursor/sanitize-connections-display-escapes-2bf7
Draft

Sanitize connection observability terminal escape sequences#1306
mscoutermarsh wants to merge 1 commit into
mainfrom
cursor/sanitize-connections-display-escapes-2bf7

Conversation

@mscoutermarsh

Copy link
Copy Markdown
Member

Summary

Connection observability (pscale branch connections show and the top TUI) was writing attacker-controllable fields from live connection snapshots (QueryText, Username, ApplicationName, ClientAddr, and related display cells) to the operator terminal without stripping control/escape bytes. Anyone with connect access to the observed branch could inject CSI/OSC sequences to spoof rows, inject hyperlinks, or write the clipboard (OSC-52) on permissive terminals.

Fix

  • Add shared SanitizeDisplayText / SanitizeMultilineDisplayText in internal/connections that strips ASCII C0 controls, DEL, and C1 controls.
  • Apply it to human show field/query sinks and to TUI sinks (queryPreview, selected status, appText, emptyDash, detail field values). Existing sanitizeFooterText now delegates to the shared helper.
  • JSON/CSV output is unchanged so machine-readable captures keep raw values.

Tests

  • Unit coverage for CSI/OSC-8/OSC-52/CR/BEL/C1 stripping and multiline query preservation.
  • Regression tests for human show output, table rows, detail records, and blocker labels.
  • go test ./internal/connections/ ./internal/connections/tui/ ./internal/cmd/branch/connections/
Open in Web Open in Cursor 

Strip C0/C1 control characters from attacker-controllable connection
fields (query text, application_name, username, client_addr, and related
display cells) in both human `show` output and the connections TUI so
CSI/OSC sequences cannot spoof the operator terminal or hijack the
clipboard.

Co-authored-by: Mike Coutermarsh <mike@planetscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants