diff --git a/SOURCES/0001-Require-authentication-for-CUPS-Get-Document.patch b/SOURCES/0001-Require-authentication-for-CUPS-Get-Document.patch new file mode 100644 index 0000000..e2852e1 --- /dev/null +++ b/SOURCES/0001-Require-authentication-for-CUPS-Get-Document.patch @@ -0,0 +1,31 @@ +From a0c8b9c9556882f00c68b9727a95a1b6d1452913 Mon Sep 17 00:00:00 2001 +From: Michael R Sweet +Date: Tue, 6 Dec 2022 09:04:01 -0500 +Subject: [PATCH] Require authentication for CUPS-Get-Document. + +--- + conf/cupsd.conf.in | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/conf/cupsd.conf.in b/conf/cupsd.conf.in +index b25884907..a07536f3e 100644 +--- a/conf/cupsd.conf.in ++++ b/conf/cupsd.conf.in +@@ -68,7 +68,13 @@ IdleExitTimeout @EXIT_TIMEOUT@ + Order deny,allow + + +- ++ ++ Require user @OWNER @SYSTEM ++ Order deny,allow ++ ++ ++ ++ AuthType Default + Require user @OWNER @SYSTEM + Order deny,allow + +-- +2.41.0 + diff --git a/SOURCES/upgrade_get_document.py.in b/SOURCES/upgrade_get_document.py.in new file mode 100755 index 0000000..91d393f --- /dev/null +++ b/SOURCES/upgrade_get_document.py.in @@ -0,0 +1,171 @@ +@PYTHON_SHEBANG@ + +""" +Upgrade script to enable authentication for CUPS-Get-Document in +default policy +""" + +import os +import sys +from shutil import copy + + +def get_cupsd_conf(): + """ + Get all lines from cupsd.conf + """ + if not os.path.exists('/etc/cups/cupsd.conf'): + return None + + lines = [] + with open('/etc/cups/cupsd.conf', 'r') as conf: + lines = conf.readlines() + + return lines + + +def get_default_policy(lines): + """ + Get the default policy lines + + :param list lines: lines from cupsd.conf + """ + default_policy = [] + in_policy = False + + for line in lines: + if not in_policy and not line.lstrip().startswith(''): + continue + + default_policy.append(line) + + if line.lstrip().startswith(''): + return default_policy + + in_policy = True + + return default_policy + + +def get_limit_with_document(lines): + """ + Get scope which defines CUPS-Get-Document operation + + :param list lines: Lines containing the default policy + """ + limit = [] + in_limit = False + + for line in lines: + if not in_limit and not line.lstrip().startswith(''): + return limit + + in_limit = True + + return limit + + +def check_for_authtype(lines): + """ + Check if defining CUPS-Get-Document defines + any authentication + + :param list lines: Lines of scope which defines CUPS-Get-Document + """ + for line in lines: + if line.lstrip().startswith('AuthType'): + return True + return False + + +def migrate_cupsd_conf(lines): + """ + Make changes to cupsd.conf contents to use authentication + for CUPS-Get-Document + + :param list lines: Lines from cupsd.conf + """ + new_lines = [] + in_policy = False + create_document_limit = False + + for line in lines: + if (in_policy and line.lstrip().startswith('') and + 'CUPS-Get-Document' in line.lstrip().split('#')[0][1:-1]): + line = line.replace(' CUPS-Get-Document', '') + create_document_limit = True + + if in_policy and line.lstrip().startswith('') and create_document_limit: + new_lines.append('\n') + new_lines.append((len(line) - len(line.lstrip()) + 2) * ' ' + + '# added during upgrade\n') + new_lines.append((len(line) - len(line.lstrip()) + 2) * ' ' + + '\n') + new_lines.append((len(line) - len(line.lstrip()) + 4) * ' ' + + 'AuthType Default\n') + new_lines.append((len(line) - len(line.lstrip()) + 4) * ' ' + + 'Require user @OWNER @SYSTEM\n') + new_lines.append((len(line) - len(line.lstrip()) + 4) * ' ' + + 'Order deny,allow\n') + new_lines.append((len(line) - len(line.lstrip()) + 2) * ' ' + + '\n') + create_document_limit = False + + new_lines.append(line) + + if not in_policy: + if line.lstrip().startswith(''): + in_policy = True + continue + + if line.lstrip().startswith(''): + new_lines.append((len(line) - len(line.lstrip()) + 2) * ' ' + + '# added during upgrade\n') + new_lines.append((len(line) - len(line.lstrip()) + 2) * ' ' + + 'AuthType Default\n') + continue + + if line.lstrip().startswith(''): + in_policy = False + continue + + return new_lines + + +def apply_changes(lines): + """ + Backup the original file if there is no .rpmsave already and + apply changes to the actual cupsd.conf + + :param list lines: New lines for cupsd.conf + """ + if not os.path.exists('/etc/cups/cupsd.conf.rpmsave'): + copy('/etc/cups/cupsd.conf', '/etc/cups/cupsd.conf.rpmsave') + + with open('/etc/cups/cupsd.conf', 'w') as conf: + conf.writelines(lines) + + + +content = get_cupsd_conf() +if content is None: + sys.exit(1) + +if check_for_authtype(get_limit_with_document(get_default_policy(content))): + sys.exit(0) + +new_content = migrate_cupsd_conf(content) + +apply_changes(new_content) + +sys.exit(0) diff --git a/SPECS/cups.spec b/SPECS/cups.spec index e5fdbea..6b1f198 100644 --- a/SPECS/cups.spec +++ b/SPECS/cups.spec @@ -7,11 +7,18 @@ # but we use lib for compatibility with 3rd party drivers (at upstream request). %global cups_serverbin %{_exec_prefix}/lib/cups +# we still need something for python2... +%if 0%{?rhel} >= 8 || 0%{?fedora} +%bcond_without python3 +%else +%bcond_with python3 +%endif + Summary: CUPS printing system Name: cups Epoch: 1 Version: 1.6.3 -Release: 51%{?dist} +Release: 52%{?dist} License: GPLv2 Group: System Environment/Daemons Url: http://www.cups.org/ @@ -27,6 +34,8 @@ Source6: cups.logrotate # Backend for NCP protocol Source7: ncp.backend Source8: macros.cups +# CVE-2023-32360 migration script +Source9: upgrade_get_document.py.in Patch1: cups-no-gzip-man.patch Patch2: cups-system-auth.patch @@ -112,6 +121,7 @@ Patch81: 0001-Fix-cupsGetPPD-with-IPP-print-queues-STR-4725.patch Patch82: cups-memory-consumption.patch Patch83: cups-cupsdsavejob-sigsegv.patch Patch84: cups-cve-rebound-fix.patch +Patch85: 0001-Require-authentication-for-CUPS-Get-Document.patch Patch100: cups-lspp.patch @@ -151,6 +161,13 @@ Requires(post): grep, sed Requires(preun): systemd Requires(postun): systemd +# for upgrade-get-document script +%if %{with python3} +Requires(post): python3 +%else +Requires(post): python +%endif + # We ship udev rules which use setfacl. Requires: systemd Requires: acl @@ -425,6 +442,8 @@ Sends IPP requests to the specified URI and tests and/or displays the results. # 1813413 - [RHEL 7.7] segfault in cupsdSaveJob() caused by no space in /var %patch83 -p1 -b .cupsdsavejob-sigsegv %patch84 -p1 -b .cve-rebound-fix +# CVE-2023-32360 cups: Information leak through Cups-Get-Document operation +%patch85 -p1 -b .get-document-auth sed -i -e '1iMaxLogSize 0' conf/cupsd.conf.in @@ -548,6 +567,15 @@ s:.*\('%{_datadir}'/\)\([^/_]\+\)\(.*\.po$\):%lang(\2) \1\2\3: /^\([^%].*\)/d ' > %{name}.lang +# install get-document upgrade script +install -m 0755 %{SOURCE9} %{buildroot}%{_sbindir}/upgrade_get_document + +%if %{with python3} + sed -i 's,@PYTHON_SHEBANG@,#!/usr/bin/python3,' %{buildroot}%{_sbindir}/upgrade_get_document +%else + sed -i 's,@PYTHON_SHEBANG@,#!/usr/bin/python,' %{buildroot}%{_sbindir}/upgrade_get_document +%endif + %post %systemd_post %{name}.path %{name}.socket %{name}.service @@ -602,6 +630,9 @@ done # remove cached information about queues (#1672212) %{_bindir}/rm -f /var/cache/cups/*.data +# CVE-2023-32324: Run script to enable authentication for CUPS-Get-Document in default policy +%{_sbindir}/upgrade_get_document + exit 0 %post client @@ -821,6 +852,9 @@ rm -f %{cups_serverbin}/backend/smb %{_mandir}/man5/ipptoolfile.5.gz %changelog +* Tue Aug 15 2023 Bryan Mason - 1:1.6.3-52 +- CVE-2023-32360 cups: Information leak through Cups-Get-Document operation + * Mon Apr 20 2020 Zdenek Dohnal - 1:1.6.3-51 - 1823758 - CVE-2017-18190 cups: DNS rebinding attacks via incorrect whitelist [rhel-7]