CVE-2024-39722

7.5 HIGH

📋 TL;DR

This vulnerability in Ollama allows attackers to discover which files exist on the server via path traversal in the api/push route. It affects all deployments of Ollama versions before 0.1.46. This information disclosure could help attackers plan further attacks.

💻 Affected Systems

Products:
  • Ollama
Versions: All versions before 0.1.46
Operating Systems: All supported platforms
Default Config Vulnerable: ⚠️ Yes
Notes: Affects all deployments where the api/push route is accessible.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers map the entire server filesystem, identify sensitive files (configs, credentials, backups), and use this information to launch targeted attacks like data theft or privilege escalation.

🟠

Likely Case

Attackers discover file paths and directory structures, potentially finding configuration files or other sensitive information that could aid in further exploitation.

🟢

If Mitigated

Limited information disclosure with no access to file contents, only existence confirmation.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

The vulnerability is simple to exploit via crafted HTTP requests to the api/push endpoint.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 0.1.46

Vendor Advisory: https://github.com/ollama/ollama/releases/tag/v0.1.46

Restart Required: Yes

Instructions:

1. Stop Ollama service. 2. Download and install version 0.1.46 or later from official sources. 3. Restart Ollama service.

🔧 Temporary Workarounds

Restrict API Access

linux

Block external access to the api/push endpoint using network controls.

iptables -A INPUT -p tcp --dport 11434 -m string --string "api/push" --algo bm -j DROP

Use Reverse Proxy Filtering

all

Configure reverse proxy (nginx, apache) to block requests containing path traversal patterns.

location ~* "\.\./" { return 403; }

🧯 If You Can't Patch

  • Implement strict network segmentation to isolate Ollama instances from untrusted networks.
  • Deploy web application firewall (WAF) rules to detect and block path traversal attempts.

🔍 How to Verify

Check if Vulnerable:

Test if you can access files outside expected directories via api/push endpoint with path traversal payloads.

Check Version:

ollama --version

Verify Fix Applied:

Attempt the same path traversal tests after patching; they should fail or return appropriate errors.

📡 Detection & Monitoring

Log Indicators:

  • HTTP requests to api/push containing "../" patterns
  • Unusual file path references in access logs

Network Indicators:

  • Multiple sequential requests to api/push with varying path parameters
  • Patterns of directory traversal attempts

SIEM Query:

source="ollama.log" AND (uri="*api/push*" AND (uri="*../*" OR uri="*..\\*"))

🔗 References

📤 Share & Export