Article View: linux.debian.bugs.dist
Article #6908Bug#1155939: cups-daemon: cupsd crashes with use-after-free when an encrypted client connection is closed
From: Max Roedl
Date: Mon, 30 Nov 2026 19:20
Date: Mon, 30 Nov 2026 19:20
129 lines
8662 bytes
8662 bytes
X-Debbugs-Cc: debian-printing@lists.debian.org Package: cups-daemon Version: 2.4.2-3+deb12u10 Severity: important Tags: security patch upstream Dear maintainers, cupsd in bookworm dies with SIGSEGV as soon as a client talks TLS (ipps://) and closes the connection afterwards. Since cupsd is restarted by systemd, the crash is easy to miss: the client just gets a reset, jobs disappear. Printing over plain ipp:// is unaffected, which is why this went unnoticed. Reproduced on Debian 12.15 (bookworm), amd64, cups-daemon 2.4.2-3+deb12u10 (binary built with OpenSSL, libcups2 linked against libssl.so.3). Steps to reproduce ------------------ 1. Make TLS usable. Note that on the Debian package TLS is broken out of the box because of a second, independent bug (see below / separate report): the default ServerKeychain does not point to the existing /etc/cups/ssl, so cupsd logs "Unable to encrypt connection: No such file or directory". # sed -i 's|^#ServerKeychain ssl|ServerKeychain /etc/cups/ssl|' /etc/cups/cups-files.conf # systemctl restart cups (CreateSelfSignedCerts defaults to yes, cupsd creates /etc/cups/ssl/<hostname>.crt/.key on its own.) 2. Send any IPP request over TLS and let the client close the connection: $ ipptool -t ipps://127.0.0.1:631/printers/<queue> \ /usr/share/cups/ipptool/get-printer-attributes.test Get printer attributes using get-printer-attributes [PASS] $ systemctl show -p MainPID --value cups # PID has changed $ journalctl -u cups --since '-2 min' | grep SEGV ... cups.service: Main process exited, code=killed, status=11/SEGV $ dmesg | tail -1 cupsd[438469]: segfault at 7f3931a47d50 ip 00007f3931a47d50 sp 00007ffffb063938 error 15 in libc.so.6[1d3d50,7f3931a47000+2000] likely on CPU 5 The same happens with an unauthenticated ipps Create-Job + Send-Document (which is answered with 401) -- no credentials are needed to trigger it. Observed / expected ------------------- cupsd segfaults; expected: connection is torn down cleanly, cupsd keeps running. Backtrace --------- Obtained by running the same source build under gdb: Thread 1 "cupsd" received signal SIGSEGV, Segmentation fault. 0x00007f19423cad50 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 #0 0x00007f19423cad50 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 #1 0x00007f1941dcedee in SSL_pending () from /lib/x86_64-linux-gnu/libssl.so.3 #2 0x00007f1942427610 in _httpTLSPending (http=<optimized out>) at ./cups/tls-openssl.c:871 #3 0x00007f194240ab05 in httpGetReady (http=<optimized out>) at ./cups/http.c:1104 #4 0x000055cc44f612d0 in main (argc=<optimized out>, argv=<optimized out>) at ./scheduler/main.c:1044 Analysis -------- cups/tls-openssl.c, _httpTLSStop(): context = SSL_get_SSL_CTX(http->tls); SSL_shutdown(http->tls); SSL_CTX_free(context); SSL_free(http->tls); <-- http->tls is left dangling } The GnuTLS backend does it correctly (cups/tls-gnutls.c: gnutls_deinit(); http->tls = NULL;). For encrypted clients, scheduler/client.c:463 (httpShutdown() in the "partial close" path of cupsdCloseClient()) tears the TLS state down, but the client stays in the Clients array for the next main loop iteration; scheduler/main.c:1044 then calls httpGetReady() -> _httpTLSPending() -> SSL_pending() on the already freed SSL object. Proposed fix (one line) ----------------------- --- a/cups/tls-openssl.c +++ b/cups/tls-openssl.c @@ -1152,6 +1152,7 @@ _httpTLSStop(http_t *http) SSL_shutdown(http->tls); SSL_CTX_free(context); SSL_free(http->tls); + http->tls = NULL; } This matches current upstream master; all released 2.4.x tarballs (v2.4.2 ... v2.4.6) lack the assignment, so an upstream backport is needed as well -- I am going to file it with OpenPrinting as well. Local rebuild with this single change survives the reproducer, 3x aborted TLS handshakes and 3x truncated POSTs (PID unchanged, no SEGV). Second, related finding (worth a separate report) ------------------------------------------------- TLS is broken out of the box: on OpenSSL builds scheduler/conf.c sets ServerKeychain to "/Library/Keychains/System.keychain" (a macOS path), and cups-files.conf only contains a commented "#ServerKeychain ssl"; since cupsd chdir()s to "/", a relative "ssl" would resolve to /ssl anyway. Result: every ipps:// client gets "cups-pki-error", the log fills with "Unable to encrypt connection: No such file or directory". Setting "ServerKeychain /etc/cups/ssl" fixes it. Upstream master maps a relative server keychain against ServerRoot (conf.c:1205ff) -- that part is missing in 2.4.2. Note: the NULL dereference reported as #1155899 is unrelated (it is a regression from the CVE-2026-27447 backport in 2.4.2-3+deb12u10 and hit the same host), but it masked this crash: while no TLS connection can be established, the use-after-free is unreachable. Regards, Maximilian, roedlmax@gmail.com
Technical Details
Message-ID:
<O5f4R-fb0Y-9@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!news-ams.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomodShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
From: Max Roedl <roedlmax@gmail.com>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1155939: cups-daemon: cupsd crashes with use-after-free when an encrypted client connection is closed
Date: Mon, 30 Nov 2026 20:20:01 +0100
Message-ID: <O5f4R-fb0Y-9@gated-at.bofh.it>
X-Original-To: submit@bugs.debian.org
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org Mon Nov 30 19:17:08 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: 2.967
Reply-To: Max Roedl <roedlmax@gmail.com>, 1155939@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: debian-printing@lists.debian.org, debian-printing@lists.debian.org
X-Debian-Pr-Message: report 1155939
X-Debian-Pr-Package: cups-daemon
X-Debian-Pr-Keywords: patch security upstream
X-Debian-Pr-Source: cups
X-Gm-Message-State: APuU4Z+/SIUTC/xfBhAojgvsQ7bnbmhzL72ALCFg2z9yeZ7/uPeZPW6i
Ev5hg6bEvQcU7S1WJg96GisanNfgHn3tVAlPp4v45wLUZU3tQ94Y79QfE84v5A==
X-Gm-Gg: AZFdTZfWRPpp7evvXx9naHVc6w3aJ6ScWJE150ctsjpPAMXG6LMOWocJxAGY3nW5c/l
X0+BkEzBhPxzirYJfypxVeMhQ4SQWZGzhNPbWK1eJ0YCbRyfcYAFYQqVKoriBnJTKmLTanbwT6e
HDDhokjvO7mbhcistBTqIE8PWbjzyh6hyLMwRYogoqGoH3D+EyeK10JWmBzXS3OcPnu7t5+n3Q8
QfDhuSzUAJQhLDFklZNRIdw+xPAewTIOsraQ9kwz/tIF1TZF7lwlN5zJf63cPYB1E9QBI820veV
BTcxwhsFVXsdG5t/zElLl3qA0jC8daFfRCQWnhGpH0z7Kp+Dwsx7yE3LY6f+XXCOdzh+shBht2o
IcMopSX10yLBT/beG4SFP89UN/8XbX4uMLxDPBZHxdN7l1BkBx9riGVP0T0RVCLUEK+7nBsi4fq
qfNiIwz+V/mRhIcSWg/wjNQQAWinoBe01EndWahcdsZPF1mEqWdMroXBYYC18ecLkAEePxFee7V
ksTactCvwMfhyx7qWG4QPgrTHsH38KxdXvXf+pnZErGQokRpP+3Yz6pG/Kk3CPQqX0hqca6tojN
eW2i0UY221lJ34srC2D7/fYMaH+UhQ==
X-Received: by 2002:a05:600c:3b8a:b0:4bb:76d9:f81a with SMTP id 5b1f17b1804b1-4bb88824fc8mr718497235e9.34.1796066148766;
Mon, 30 Nov 2026 11:15:48 -0800 (PST)
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2006146
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 129
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Mon, 30 Nov 2026 20:15:47 +0100
X-Original-Message-ID: <0c950ce0-42fe-45ec-b119-f63f9b4f1ec4@gmail.com>