Hi,

I've prepared kitty 0.26.5-5+deb12u2 for bookworm-security. Attached is
the debdiff ready for review, and attached is a draft DLA announcement
also.

I have also backported this patch alongside a few others to trixie and
sent to the security team. I will reserve the DLA and upload this once
they issue a DSA if there are no issues.

[ Changes ]

  * CVE-2026-95835: Verify owner and permissions of SHM memory used for
    askpass in the ssk kitten.
        
[ Details ]

The version of kitty in bookworm is only affected by CVE-2026-95835.
Other CVEs did not impact bookworm so I've marked them as such in the
security tracker.

This patch follows upstream's in that it moves the shm permission check
out of read_data_from_shared_memory (kittens/ssh/main.py) into a new
class method verify_owner_and_mode (kitty/shm.py), and then uses this
new method in handle_remote_askpass (kitty/window.py) alongside related
changes.

The main difference is that verify_owner_and_mode allows for the mode to
be either stat.S_IREAD (400) or stat.S_IREAD | stat.S_IWRITE (600),
compared to originally only permitting stat.S_IREAD (400) when it was in
read_data_from_shared_memory. At handle_remote_askpass it is 600, but
the bookworm code that uses read_data_from_shared_memory still sets it
to 400 (in newer versions of kitty this is not the case, it is also
600).

[ Tests ]

Tests during build and autopkgtest continue to pass. Smoke testing for
kitty and the ssh kitten (`kitty +kitten ssh <host>` while inside kitty)
were also fine.

[ Build ]

Debusine: https://debusine.debian.net/debian/developers/work-request/1688585/

Salsa: https://salsa.debian.org/debian/kitty/-/tree/debian/bookworm-security

--
Maytham
-------------------------------------------------------------------------
Debian LTS Advisory DLA-XXXX-1                [email protected]
https://www.debian.org/lts/security/                     Maytham Alsudany
December 02, 2026                             https://wiki.debian.org/LTS
-------------------------------------------------------------------------

Package        : kitty
Version        : 0.26.5-5+deb12u2
CVE ID         : CVE-2026-95835
Debian Bug     : 1149729

A vulnerability was discovered in Kitty, a GPU-based terminal emulator,
which may result in disclosure of sensitive information.

For Debian 12 bookworm, this problem has been fixed in version
0.26.5-5+deb12u2.

We recommend that you upgrade your kitty packages.

For the detailed security status of kitty please refer to
its security tracker page at:
https://security-tracker.debian.org/tracker/kitty

Further information about Debian LTS security advisories, how to apply
these updates to your system and frequently asked questions can be
found at: https://wiki.debian.org/LTS
diff -Nru kitty-0.26.5/debian/changelog kitty-0.26.5/debian/changelog
--- kitty-0.26.5/debian/changelog	2026-11-23 02:00:55.000000000 +0800
+++ kitty-0.26.5/debian/changelog	2026-12-01 16:06:42.000000000 +0800
@@ -1,3 +1,11 @@
+kitty (0.26.5-5+deb12u2) bookworm-security; urgency=high
+
+  * Non-maintainer upload by the LTS Team.
+  * CVE-2026-95835: Verify owner and permissions of SHM memory used for
+    askpass in the ssk kitten.
+
+ -- Maytham Alsudany <[email protected]>  Tue, 01 Dec 2026 16:06:42 +0800
+
 kitty (0.26.5-5+deb12u1) bookworm-security; urgency=high
 
   * Non-maintainer upload by the LTS Team.
diff -Nru kitty-0.26.5/debian/patches/CVE-2026-95835.patch kitty-0.26.5/debian/patches/CVE-2026-95835.patch
--- kitty-0.26.5/debian/patches/CVE-2026-95835.patch	1970-01-01 08:00:00.000000000 +0800
+++ kitty-0.26.5/debian/patches/CVE-2026-95835.patch	2026-12-01 16:06:42.000000000 +0800
@@ -0,0 +1,147 @@
+From 3281919056c442e4ba6f5abed7ee2c5130de31ff Mon Sep 17 00:00:00 2001
+From: Kovid Goyal <[email protected]>
+Date: Tue, 1 Sep 2026 20:14:03 +0530
+Subject: [PATCH] ssh kitten: Verify owner and permissions of SHM memory used
+ for askpass
+
+--- a/kitty/shm.py
++++ b/kitty/shm.py
+@@ -152,6 +152,16 @@
+     def fileno(self) -> int:
+         return self._fd
+ 
++    def verify_owner_and_mode(self) -> None:
++        """Ensure the shared memory object is owned by us and not accessible to
++        any other user. Must be called when opening objects whose name comes
++        from an untrusted source, as anyone can create an object of that name."""
++        if self.stats.st_uid != os.geteuid() or self.stats.st_gid != os.getegid():
++            raise ValueError(f'Incorrect owner on shared memory object: uid={self.stats.st_uid} gid={self.stats.st_gid}')
++        mode = stat.S_IMODE(self.stats.st_mode)
++        if mode != stat.S_IREAD and mode != stat.S_IREAD | stat.S_IWRITE:
++            raise ValueError(f'Incorrect permissions on shared memory object: 0o{mode:03o}')
++
+     def __repr__(self) -> str:
+         return f'{self.__class__.__name__}({self.name!r}, size={self.size})'
+ 
+--- a/kitty/window.py
++++ b/kitty/window.py
+@@ -54,7 +54,7 @@
+ from .typing import BossType, ChildType, EdgeLiteral, TabType, TypedDict
+ from .utils import (
+     docs_url, kitty_ansi_sanitizer_pat, load_shaders, log_error, open_cmd, open_url,
+-    parse_color_set, path_from_osc7_url, resolve_custom_file, resolved_shell,
++    parse_color_set, path_from_osc7_url, resolve_custom_file, resolved_shell, sanitize_control_codes,
+     sanitize_for_bracketed_paste, sanitize_title,
+ )
+ 
+@@ -1134,34 +1134,56 @@
+             from .launch import clone_and_launch
+             clone_and_launch(cdata, self)
+ 
+-    def handle_remote_askpass(self, msg: str) -> None:
++    def handle_remote_askpass(self, name: str) -> None:
+         from .shm import SharedMemory
+-        with SharedMemory(name=msg, readonly=True) as shm:
++        try:
++            shm = SharedMemory(name=name)
++        except OSError as err:
++            log_error(f'Ignoring ask request as opening its shared memory object failed with error: {err}')
++            return
++        try:
++            # The askpass client polls its own mapping for the answer, so
++            # unlinking the name here does not affect it and prevents anyone
++            # else from opening this object while we are using it.
++            shm.unlink()
++            shm.verify_owner_and_mode()
+             shm.seek(1)
+             data = json.loads(shm.read_data_with_size())
++            q = str(data['type'])
++            message: str = sanitize_control_codes(data['message'])
++            choices = tuple(map(sanitize_control_codes, data['choices'])) if q == 'choose' else ()
++        except Exception as err:
++            shm.close()
++            log_error(f'Ignoring invalid ask request with error: {err}')
++            return
+ 
+         def callback(ans: Any) -> None:
+-            data = json.dumps(ans)
+-            with SharedMemory(name=msg) as shm:
++            try:
+                 shm.seek(1)
+-                shm.write_data_with_size(data)
++                shm.write_data_with_size(json.dumps(ans))
+                 shm.flush()
+                 shm.seek(0)
+                 shm.write(b'\x01')
++            finally:
++                shm.close()
+ 
+-        message: str = data['message']
+-        if data['type'] == 'confirm':
++        if q == 'confirm':
+             get_boss().confirm(
+                 message, callback, window=self, confirm_on_cancel=bool(data.get('confirm_on_cancel')),
+                 confirm_on_accept=bool(data.get('confirm_on_accept', True)))
+-        elif data['type'] == 'choose':
+-            get_boss().choose(
+-                message, callback, *data['choices'], window=self, default=data.get('default', ''))
+-        elif data['type'] == 'get_line':
++        elif q == 'choose':
++            get_boss().choose(message, callback, *choices, window=self, default=data.get('default', ''))
++        elif q == 'get_line':
+             get_boss().get_line(
+-                message, callback, window=self, is_password=bool(data.get('is_password')), prompt=data.get('prompt', '> '))
++                message,
++                callback,
++                window=self,
++                is_password=bool(data.get('is_password')),
++                prompt=sanitize_control_codes(data.get('prompt', '> ')),
++            )
+         else:
+-            log_error(f'Ignoring ask request with unknown type: {data["type"]}')
++            shm.close()
++            log_error(f'Ignoring ask request with unknown type: {q}')
+ 
+     def handle_remote_print(self, msg: str) -> None:
+         text = process_remote_print(msg)
+--- a/kittens/ssh/main.py
++++ b/kittens/ssh/main.py
+@@ -59,11 +59,7 @@
+ def read_data_from_shared_memory(shm_name: str) -> Any:
+     with SharedMemory(shm_name, readonly=True) as shm:
+         shm.unlink()
+-        if shm.stats.st_uid != os.geteuid() or shm.stats.st_gid != os.getegid():
+-            raise ValueError('Incorrect owner on pwfile')
+-        mode = stat.S_IMODE(shm.stats.st_mode)
+-        if mode != stat.S_IREAD:
+-            raise ValueError('Incorrect permissions on pwfile')
++        shm.verify_owner_and_mode()
+         return json.loads(shm.read_data_with_size())
+ 
+ 
+--- /dev/null
++++ b/kitty_tests/shm.py
+@@ -0,0 +1,23 @@
++#!/usr/bin/env python
++# License: GPLv3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net>
++
++
++import os
++
++from kitty.shm import SharedMemory
++
++from . import BaseTest
++
++
++class SHMTest(BaseTest):
++
++    def test_shm_ownership_verification(self):
++        with SharedMemory(size=64, unlink_on_exit=True) as shm:
++            for mode in (0o644, 0o660):
++                os.fchmod(shm.fileno(), mode)
++                with SharedMemory(name=shm.name, readonly=True) as shm2:
++                    self.assertRaises(ValueError, shm2.verify_owner_and_mode)
++            for mode in (0o600, 0o400):
++                os.fchmod(shm.fileno(), mode)
++                with SharedMemory(name=shm.name, readonly=True) as shm2:
++                    shm2.verify_owner_and_mode()
diff -Nru kitty-0.26.5/debian/patches/series kitty-0.26.5/debian/patches/series
--- kitty-0.26.5/debian/patches/series	2026-11-23 00:39:26.000000000 +0800
+++ kitty-0.26.5/debian/patches/series	2026-12-01 16:06:42.000000000 +0800
@@ -10,3 +10,4 @@
 CVE-2026-42851.patch
 CVE-2026-54055.patch
 CVE-2026-72913.patch
+CVE-2026-95835.patch

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to