Sanitize connection observability terminal escape sequences#1306
Draft
mscoutermarsh wants to merge 1 commit into
Draft
Sanitize connection observability terminal escape sequences#1306mscoutermarsh wants to merge 1 commit into
mscoutermarsh wants to merge 1 commit into
Conversation
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>
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
Connection observability (
pscale branch connections showand thetopTUI) 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
SanitizeDisplayText/SanitizeMultilineDisplayTextininternal/connectionsthat strips ASCII C0 controls, DEL, and C1 controls.showfield/query sinks and to TUI sinks (queryPreview, selected status,appText,emptyDash, detail field values). ExistingsanitizeFooterTextnow delegates to the shared helper.Tests
go test ./internal/connections/ ./internal/connections/tui/ ./internal/cmd/branch/connections/