Add Ollama path traversal RCE module (CVE-2024-37032)#21006
Open
Chocapikk wants to merge 3 commits intorapid7:masterfrom
Open
Add Ollama path traversal RCE module (CVE-2024-37032)#21006Chocapikk wants to merge 3 commits intorapid7:masterfrom
Chocapikk wants to merge 3 commits intorapid7:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello Metasploit Team,
This PR adds a new exploit module for CVE-2024-37032 ("Probllama"), a path traversal vulnerability in Ollama < 0.1.34 that chains into unauthenticated RCE as root.
Summary
Ollama's model pull mechanism accepts OCI manifests where the digest field is not validated. Instead of enforcing
sha256:<64hex>, it accepts arbitrary path traversal sequences (../../../etc/ld.so.preload). This allows a rogue OCI registry to write arbitrary files on the server.Existing public PoCs (jakabakos, Bi0x) only demonstrate file read/write. This module is the first to chain the arbitrary write into a full RCE with session.
Exploitation flow
The module starts a rogue OCI registry (HttpServer mixin) and performs three steps against the target:
Pull 1 (path traversal write) - Serves a malicious manifest with three layers. The first layer is sacrificial (absorbs Ollama's SHA256 digest verification failure and gets deleted). The remaining two layers persist unverified: a shared library containing the payload as a
DT_INITconstructor, and/etc/ld.so.preloadpointing to it.Pull 2 (trigger model registration) - Serves a valid model with correct SHA256 digests and a minimal GGUF header. Ollama registers this model, making it available for
/api/chat. The module then aliases it to a random name and deletes the original to remove the attacker's URL from/api/tags.Trigger (
/api/chat) - Ollama spawns the llama.cpp runner process. The dynamic linker reads/etc/ld.so.preloadand loads the malicious.so. The constructor unlinksld.so.preload(prevents re-execution), forks (parent returns so the runner starts normally), and the child executes the payload viammap+memcpyto an RWX page. The trigger model is deleted in anensureblock regardless of outcome.Key techniques
.sois compiled from C usingMetasm::ELF.compile_cwithexternlibc declarations forfork,unlink,setsid,mmap,memcpy. No raw assembly.Faker::Hackerto avoid obvious IOC strings in Ollama's logs.FileDroppercleans up the.so, the constructor unlinksld.so.preload, and both the trigger model and its alias are deleted via the Ollama API.Vulnerable versions
0.0.0.0:11434(no authentication)Verification
Ollama 0.1.33 on Docker (Linux x64)