Skip to main content
Vulnerability Database/CVE-2026-80431

CVE-2026-80431: Kitty Terminal Buffer Overflow Vulnerability

CVE-2026-80431 is a buffer overflow flaw in Kitty terminal emulator versions 0.40.0 to 0.49.0 that allows malicious programs to crash the terminal. This post explains its technical details, impact, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-80431 Overview

CVE-2026-80431 is an out-of-bounds write vulnerability [CWE-787] in the kitty terminal emulator, affecting versions 0.40.0 through 0.48.2. The flaw resides in the natural width branch of the text sizing protocol. A program writing to the terminal can send an OSC 66 escape code containing a grapheme cluster longer than four codepoints, which overflows a fixed-size stack buffer in screen_handle_multicell_command(). Each additional codepoint writes one 32-bit value past the buffer boundary. Successful exploitation terminates the kitty process along with all its windows, tabs, and child processes.

Critical Impact

Any process that can write to a kitty terminal, including output from cat, curl, or SSH sessions displaying attacker-controlled data, can crash the terminal and kill all running child processes within it.

Affected Products

  • kitty terminal emulator version 0.40.0
  • kitty terminal emulator versions through 0.48.2
  • Fixed in kitty version 0.49.0

Discovery Timeline

  • 2026-09-25 - CVE-2026-80431 published to NVD
  • 2026-09-29 - Last updated in NVD database

Technical Details for CVE-2026-80431

Vulnerability Analysis

The vulnerability is a classic out-of-bounds write triggered by untrusted terminal output. The RAII_ListOfChars macro declares lc as a four-element char_type array on the function stack frame of screen_handle_multicell_command() in kitty/screen.c. When processing an OSC 66 text sizing escape code without an explicit width (w) key, the natural width branch appends each codepoint of a grapheme cluster to lc.chars using lc.chars[lc.count++] = ch with no capacity check.

A grapheme cluster longer than four codepoints writes one 32-bit value beyond the buffer per additional codepoint, in the order the codepoints appear. If an intermediate flush occurs earlier in the same payload, ensure_space_for_chars() migrates the buffer to the heap, and the subsequent write overflows the heap allocation instead. The outcome is memory corruption that terminates the kitty process and kills all its tabs, windows, and child processes.

Root Cause

The root cause is a missing bounds check in the grapheme cluster accumulation path. The code assumed grapheme clusters would not exceed the four-codepoint stack buffer, an assumption that Unicode does not guarantee. The fix adds a call to ensure_space_for_chars(&lc, lc.count + 1) before each append to grow the buffer as needed.

Attack Vector

Exploitation requires local delivery of attacker-controlled output to a kitty terminal. Common vectors include cat-ing a crafted file, viewing hostile log data, SSH sessions to compromised hosts, or displaying unsanitized web content through a terminal client. User interaction is required, but no privileges are needed on the terminal process itself.

c
            char_type ch = self->lc->chars[i];
            CharProps cp = char_props_for(ch);
            if (cp.is_invalid) continue;
-            if ((s = grapheme_segmentation_step(s, cp)).add_to_current_cell || (wcwidth_std(cp) == 0 && lc.count)) lc.chars[lc.count++] = ch;
-            else {
+            if ((s = grapheme_segmentation_step(s, cp)).add_to_current_cell || (wcwidth_std(cp) == 0 && lc.count)) {
+                ensure_space_for_chars(&lc, lc.count + 1);
+                lc.chars[lc.count++] = ch;
+            } else {
                 if (lc.count) handle_variable_width_multicell_command(self, mcd, &lc);
                 switch (wcwidth_std(cp)) {
                     case 0:

Source: kitty commit 7d2fbaa

Detection Methods for CVE-2026-80431

Indicators of Compromise

  • Unexpected termination of kitty terminal processes along with all child shells and tabs.
  • Presence of OSC 66 escape sequences in log files, downloaded content, or SSH session output.
  • Core dumps or crash reports referencing screen_handle_multicell_command in kitty/screen.c.

Detection Strategies

  • Scan files and network streams for the OSC 66 escape sequence (ESC ] 66) containing grapheme clusters that extend beyond four codepoints.
  • Monitor process termination events for kitty with abnormal exit codes correlated with recent terminal output activity.
  • Audit installed kitty versions across endpoints and flag any build between 0.40.0 and 0.48.2.

Monitoring Recommendations

  • Collect endpoint telemetry on terminal application crashes and parent-child process trees for abrupt losses of interactive shells.
  • Enable crash reporting on developer and administrator workstations where kitty is used for SSH access.
  • Alert on repeated kitty crashes from the same user context, which may indicate repeated exploitation attempts.

How to Mitigate CVE-2026-80431

Immediate Actions Required

  • Upgrade kitty to version 0.49.0 or later on all systems where it is installed.
  • Inventory workstations and developer environments to identify vulnerable kitty installations between 0.40.0 and 0.48.2.
  • Avoid displaying untrusted file contents or remote output through vulnerable kitty terminals until patched.

Patch Information

The fix is included in kitty release v0.49.0. The patch adds an ensure_space_for_chars() call before each codepoint append in the natural width branch of the text sizing protocol handler. Technical analysis of the patch is available in the upstream commit and the secur0 CVE analysis.

Workarounds

  • Pipe untrusted output through a sanitizer such as cat -v or less -R with escape filtering before rendering in kitty.
  • Use an alternate terminal emulator for sessions that handle untrusted data until the upgrade is applied.
  • Disable or restrict terminal features that render extended text sizing escape sequences in automation pipelines.
bash
# Verify installed kitty version and upgrade
kitty --version

# Upgrade on macOS via Homebrew
brew upgrade kitty

# Upgrade on Linux using the official installer
curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.