fix: sanitize streamed model output before terminal rendering - #550
Open
Gautam Sharma (GautamSharma99) wants to merge 1 commit into
Open
fix: sanitize streamed model output before terminal rendering#550Gautam Sharma (GautamSharma99) wants to merge 1 commit into
Gautam Sharma (GautamSharma99) wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: ff2541e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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
Fixes #540.
Interactive assistant Markdown was passed to Ink after lexing without removing terminal control protocols. Repository and connector content can influence model output, so OSC 52 clipboard writes, OSC 8 hyperlinks, CSI cursor/display controls, and related sequences could reach a user terminal.
Changes
stripTerminalControlSequences, a boundary sanitizer that removes:marked.lexer, covering paragraphs, headings, lists, blockquotes, inline/fenced code, tables, HTML, and fallback tokens without re-sanitizing Ink-generated styling.Security rationale
The model output is untrusted terminal text. Sanitizing before Markdown parsing ensures no rendered token path can accidentally bypass the control-sequence policy, while Ink remains responsible for intentional application styling after the untrusted boundary.
Validation
pnpm run lint:checkpnpm run typecheckpnpm exec prettier --check(changed files)pnpm test— 67 files, 795 tests passed