/

CVE-2026-54057

Severity:

HIGH RISK

(7.8)

Command Injection via OSC Color Control in Kitty Terminal

CVE-2026-54057

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-94, CWE-150

Impact:

Remote Command Execution in Terminal Session

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Kitty terminals before 0.47.3 mishandle OSC 21 color-control query replies by reflecting attacker-controlled bytes, including newlines, directly into the shell input.

Under conditions where a remote host or process can emit crafted OSC sequences, this can lead to unintended command execution in the user's shell.

Affected context

The vulnerability occurs in environments where the Kitty terminal is used to connect to systems or processes capable of emitting OSC 21 (color-control) sequences.

When Kitty processes a color query reply, it reflects unvalidated response bytes back into the shell input line.

This behavior becomes risky when the terminal is attached to an interactive shell and the remote endpoint is not fully trusted, such as SSH sessions, multiplexer sessions, or tools that can output arbitrary escape sequences.

Exploit preconditions

  • Attack surface: Interactive Kitty terminal sessions handling OSC 21 color-control sequences
  • Required access: Ability for an attacker-controlled system or process to write arbitrary OSC escape sequences to the terminal
  • Trigger point: Reception of a crafted OSC 21 reply containing embedded command text and newline characters
  • Why exploitation is possible: The terminal reflects response bytes directly into the shell input without sanitizing control characters or separating protocol data from user input

Why this happens

The root cause is improper separation between control protocol handling and user input streams in the terminal.

Kitty's OSC 21 (color-control) handling logic treated the reply as safe to reinject into the shell input, without sanitizing or filtering newline and other control characters.

This maps to CWE-94 (Improper Control of Generation of Code) because user-controllable data is effectively turned into shell commands, and CWE-150 (Improper Neutralization of Escape, Meta, or Control Sequences) due to inadequate handling of terminal control sequences that influence command input.

Potential impact

  • Injection of arbitrary shell commands into the user's interactive session
  • Execution of commands under the user's account, potentially leading to data exfiltration
  • Modification of configuration files or environment settings in the current session
  • Pivoting to other systems reachable from the compromised shell

General mitigation guidance

Mitigation generally focuses on isolating control sequences from shell input and treating all terminal escape replies as untrusted data.

Useful patterns include:

  • Sanitizing OSC replies to strip or neutralize newline and other command-delimiting characters before they reach the shell input
  • Ensuring that protocol responses are handled internally by the terminal and never reinjected into user input streams
  • Applying strict parsing and validation of control sequences, rejecting malformed or unexpected content
  • Running interactive shells with least-privilege and limiting the trust placed in remote endpoints that can emit escape sequences

How teams detect issues like this

Detection can rely on both behavioral and code-level signals:

  • Reviewing terminal code paths where OSC or other control sequences are processed and checking for any reflection into input streams
  • Using static analysis or linters to flag code that mixes control protocol handling with user input injection
  • Instrumenting terminals or shells to log unexpected escape sequences and monitoring for suspicious command patterns appearing without user typing
  • Incorporating security-focused code reviews around terminal emulation and escape sequence parsing logic

Sources

SourceLink
github.comgithub.com/kovidgoyal/kitty/security/advisories/GHSA-5gmr-9gwg-hhq6

Frequently asked

questions

It can be, in the sense that a remote system you connect to via Kitty can send crafted OSC sequences that result in command injection into your local shell, provided the session is interactive and processes those sequences.

An attacker needs the ability to emit arbitrary output to your Kitty terminal, such as control over a remote host you SSH into, a compromised multiplexer session, or any program whose output reaches your terminal.

The safest pattern is to ensure that control sequence responses are never written back into shell input, and to sanitize all escape sequences, especially removing or neutralizing newlines and characters that delimit commands.

Future prevention should rely on strict separation between control protocols and user input, comprehensive validation of escape sequences, and security reviews focused on terminal emulation paths where external data can influence shell command streams.

Find out what's already
exploitable in your codebase.