From eea172967848bb4c5a407329f40c0e45de0d187e Mon Sep 17 00:00:00 2001
From: Jan Rybar <jrybar@redhat.com>
Date: Thu, 27 Aug 2026 15:02:45 +0200
Subject: [PATCH] CVE-2026-85498: Unsanitized underflow in cookie input

Credits for the report:
Sunwoo Lee, Korea Institute of Energy Technology (KENTECH)
Daeyoung Kang, Korea Institute of Energy Technology (KENTECH)
Haeryong Park, Korea Internet & Security Agency (KISA)
Hyuk Lim, Korea Institute of Energy Technology (KENTECH)
Seunghyun Yoon, Korea Institute of Energy Technology (KENTECH)
Juthawong Naisanguansee

Co-authored-by: Jan Rybar <jrybar@redhat.com>

CVE: CVE-2026-85498
Upstream-Status: Backport [https://github.com/polkit-org/polkit/commit/eea172967848bb4c5a407329f40c0e45de0d187e]
Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
 src/polkitagent/polkitagenthelperprivate.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/polkitagent/polkitagenthelperprivate.c b/src/polkitagent/polkitagenthelperprivate.c
index c0a9825..e2d2c9b 100644
--- a/src/polkitagent/polkitagenthelperprivate.c
+++ b/src/polkitagent/polkitagenthelperprivate.c
@@ -68,6 +68,11 @@ read_cookie (int argc, char **argv)
             perror ("fgets");
           return NULL;
         }
+      if (buf[0] == '\0')
+        {
+          errno = EINVAL;
+          return NULL;
+        }
       if (buf[strlen (buf) - 1] != '\n')
         {
           errno = EOVERFLOW;
