Repository navigation
Conversation
…injection This fix addresses CVE-2026-XXXX by sanitizing terminal control characters and escape sequences when outputting to a TTY. This prevents malicious HTTP responses from injecting terminal escape sequences that could manipulate the user's terminal display, change titles, inject clipboard content, or potentially exploit terminal vulnerabilities. The fix: 1. Adds a sanitize_for_terminal() function that removes ANSI escape sequences, OSC escape sequences, and other terminal control characters 2. Applies this sanitization in all stream processing classes when outputting to a TTY (when env.stdout_isatty is True) 3. Preserves raw data when output is redirected to files or pipes Fixes httpie#1812
vinayK34
marked this pull request as ready for review
October 31, 2026 14:10
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.
This PR fixes CVE-2026-XXXX by sanitizing terminal control characters and escape sequences when outputting to a TTY. This prevents malicious HTTP responses from injecting terminal escape sequences that could manipulate the user's terminal display, change titles, inject clipboard content, or potentially exploit terminal vulnerabilities.
Changes
sanitize_for_terminal()function that removes ANSI escape sequences, OSC escape sequences, and other terminal control charactersEncodedStream,PrettyStream,BufferedPrettyStream) when outputting to a TTY (whenenv.stdout_isattyis True)Fixes
Fixes #1812
Testing
The fix has been tested with various escape sequences including:
\x1b[31mRed Text\x1b[0m)\x1b]2;Title\x07)\x1b[2J\x1b[H)\x01\x02)All escape sequences are properly removed when outputting to a TTY, preventing terminal manipulation attacks.