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

CVE-2026-95834: Kitty Terminal Use-After-Free Vulnerability

CVE-2026-95834 is a use-after-free flaw in Kitty terminal emulator versions 0.47.0 to 0.49.0 affecting drag and drop operations. Attackers can trigger memory corruption through terminal output. This post covers technical details, affected versions, impact assessment, and mitigation strategies.

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-95834 Overview

CVE-2026-95834 is a use-after-free vulnerability [CWE-416] in the drag source path of the drag and drop protocol in the kitty terminal emulator. The flaw affects versions from 0.47.0 before 0.49.0. Any program writing to the terminal can trigger the terminal process to read from and write to freed heap memory. The bug resides in drag_remote_file_data() in kitty/dnd.c, which continues to use a DragRemoteItem pointer after helper functions have torn down and freed the owning offer structure through cancel_drag() and drag_free_offer().

Critical Impact

A hostile byte stream written to the terminal window can cause undefined behavior in the kitty terminal process, including reads and writes against freed heap memory.

Affected Products

  • kitty terminal emulator versions 0.47.0 through 0.48.x
  • Fixed in kitty 0.49.0
  • Component: kitty/dnd.c drag and drop protocol handler

Discovery Timeline

  • 2026-09-25 - CVE-2026-95834 published to NVD
  • 2026-09-29 - Last updated in NVD database
  • kitty v0.49.0 release - Fix shipped in upstream commit b54bfbb4f85f992edca9b04f5c0c2612454eec23

Technical Details for CVE-2026-95834

Vulnerability Analysis

The root issue is a lifetime mismatch between the caller drag_remote_file_data() and the helper functions toplevel_data_for_drag() and subdir_data_for_drag(). The caller holds a DragRemoteItem pointer into an array it does not own, invokes the helpers, and then continues to dereference that pointer after they return. Those helpers, along with add_payload() and populate_dir_entries(), report errors through the abrt() macro. The macro expands to cancel_drag() followed by a plain return, and cancel_drag() calls drag_free_offer(), which frees the backing array.

Because the helpers return void, the caller receives no signal that teardown has occurred. The caller then invokes all_children_complete() on the freed pointer, dereferencing it and subsequently writing through it. This condition is reachable from the raw byte stream of any program running inside the terminal window.

Root Cause

The dereference is guarded by a local flag that is set when the request carries no payload and announces no further data. That same condition selects the finalisation block of add_payload(), so error paths in that block become reachable. Trigger conditions include a create that fails because an entry of the same name already exists (clients may declare two entries with one name while create operations use O_CREAT with O_EXCL and symlinkat()), a mkdirat() failure other than EEXIST, and failures in the directory entry allocation path. In the top-level branch the caller's pointer is never cleared, so clearing the owning structure's own pointers during teardown does not help. In the sub-directory branch, subdir_data_for_drag() leaves the caller holding a freed child node inside the item tree, which drag_free_offer() releases recursively.

Attack Vector

Exploitation requires local user interaction with a drag and drop operation initiated through the terminal. Any program that writes to the terminal, including output piped from a remote ssh session, can emit the escape sequences that drive the drag and drop protocol. A crafted drag source item that is aborted mid-transfer triggers the use-after-free in the terminal process.

c
// Upstream fix: helpers now return bool so callers can detect teardown.
// Source: https://github.com/kovidgoyal/kitty/commit/b54bfbb4f85f992edca9b04f5c0c2612454eec23

// The following functions can abort the drag when they encounter an error.
// Aborting calls cancel_drag() -> drag_free_offer(), which frees the offer
// including the DragRemoteItem the caller is holding. They therefore return
// false on abort (and true otherwise) so callers know to stop touching the now
// freed memory. abrt() is redefined here to return false instead of void; it is
// restored to its void form after subdir_data_for_drag().
#undef abrt
#define abrt(code, details)            \
    {                                  \
        cancel_drag(w, code, details); \
        return false;                  \
    }

static bool
populate_dir_entries(Window *w, DragRemoteItem *ri) {
    size_t num = count_occurrences((char *)ri->data, ri->data_sz, 0) + 1;
    ri->children = calloc(num + 1, sizeof(ri->children[0]));

Detection Methods for CVE-2026-95834

Indicators of Compromise

  • Unexpected crashes or segmentation faults in kitty processes while a drag and drop operation is in progress.
  • Terminal sessions emitting drag protocol escape sequences from untrusted remote hosts or scripts.
  • Core dumps from kitty referencing drag_remote_file_data, drag_free_offer, or all_children_complete in the stack trace.

Detection Strategies

  • Inventory installed kitty versions across workstations and flag any instance from 0.47.0 up to but not including 0.49.0.
  • Monitor process telemetry for abnormal termination of kitty correlated with incoming terminal data from ssh, tmux, or piped output.
  • Review audit logs for execution of untrusted scripts or binaries that write directly to a kitty TTY.

Monitoring Recommendations

  • Enable crash reporting and ingest system crash logs into a centralized log platform for correlation.
  • Alert on repeated kitty segfaults from the same user session, which may indicate exploitation attempts.
  • Track package manager events for kitty upgrades to confirm patch deployment at scale.

How to Mitigate CVE-2026-95834

Immediate Actions Required

  • Upgrade all kitty installations to version 0.49.0 or later as soon as distribution packages are available.
  • Audit shared or multi-user systems where developers run kitty with elevated privileges and prioritize those hosts.
  • Avoid piping untrusted output directly into a kitty terminal until patching is complete.

Patch Information

The vulnerability is fixed in kitty 0.49.0. The upstream fix is commit b54bfbb4f85f992edca9b04f5c0c2612454eec23, which refactors the abrt() macro and converts populate_dir_entries(), add_payload(), toplevel_data_for_drag(), and subdir_data_for_drag() to return bool so that callers can detect when the drag offer has been torn down. See the GitHub commit and the kitty v0.49.0 release notes for full details. Additional analysis is available in the SecuR0 CVE-2026-95834 writeup.

Workarounds

  • Disable the drag and drop protocol in kitty configuration if the feature is not required for daily work.
  • Restrict terminal sessions to trusted sources and avoid rendering output from untrusted network services inside kitty.
  • Isolate kitty usage in container or sandbox environments where crashes have limited blast radius.
bash
# Verify your installed kitty version and upgrade
kitty --version

# Example upgrade paths
# Arch Linux
sudo pacman -Syu kitty

# Homebrew (macOS)
brew update && brew upgrade kitty

# Official installer (replaces in ~/.local)
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.