Ollama Vulnerability Enables Remote Code Execution via Path Traversal

Summary
Wiz researchers detailed CVE-2024-37032, which lets attackers exploit path traversal in Ollama to read or overwrite files and achieve remote code execution in some deployments. Ollama fixed the flaw in version 0.1.34.
Key points
- The flaw affects Ollama’s API server and stems from insufficient validation of model-manifest digest fields supplied when pulling from private registries.
- A crafted manifest can trigger path traversal, enabling arbitrary file writes and, through a planted manifest and push request, file reads.
- In Docker deployments, the server runs as root and listens on 0.0.0.0 by default, which can make remote exploitation possible.
- Wiz demonstrated an RCE chain that writes a shared library, alters /etc/ld.so.preload, and triggers a new process through the /api/chat endpoint.
- Wiz reported more than 1,000 internet-exposed Ollama instances in its scan, including instances hosting private models.
- Ollama released a fix on May 8, 2024; users should upgrade to version 0.1.34 or newer and avoid internet exposure without authentication protection.
- The default Linux installation binds the API server to localhost, reducing remote exploitation risk, according to the article.
Article Details
- Vulnerability Types
- Path traversal
- Arbitrary file write
- Arbitrary file read
- Remote code execution
- Severity
- Critical
- Exploitation Status
- unknown
- Exploit Availability
- public_poc
- Patch Status
- available
- Workarounds
- Do not expose Ollama to the internet unless it is protected by authentication, such as through a reverse proxy.
MITRE ATT&CK
T1190 · Exploit Public-Facing ApplicationThe vulnerability can be exploited remotely by sending specially crafted HTTP requests to an exposed Ollama API server.T1574.006 · Dynamic Linker HijackingThe demonstrated Docker exploitation writes a shared library and adds it to /etc/ld.so.preload so it loads when a new process starts.
