CVE-2026-87690: Metasploit Framework ios_image_gather Path Traversal Leading to Arbitrary File Write and Code Execution
The Metasploit Framework post module post/appleios/gather/iosimagegather is affected by a relative path traversal vulnerability (CWE-22). The module interpolates file names taken from a Meterpreter directory listing — data fully controlled by a hostile or tampered iOS device — directly into the local destination path passed to client.fs.file.downloadfile(), with no sanitization. The underlying stdapi sink (lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb) writes to whatever path is supplied, so a listing entry such as ../../msfconsole.rc escapes the intended ~/.msf4/loot/<random> directory and overwrites ~/.msf4/msfconsole.rc, a resource file that every msfconsole invocation automatically executes at startup (lib/msf/ui/console/driver.rb:196). An attacker-controlled device that lures an operator into running this gather module achieves an arbitrary file write as the operator; because the written msfconsole.rc can load a second written file (a Ruby plugin whose top-level code runs on require), this converts into persistent code execution and an interactive shell as the operator (frequently root) on the pentester's workstation at the next console launch. The same traversal was previously fixed upstream in the recursive downloader (stdapi/fs/dir.rb scrubs separators); this module omitted the equivalent scrub. The fix applies the same separator scrub (or File.basename) to listing entries before building the local path.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
Metasploit Frameworkto a version that resolves this vulnerability.Fixed in 6.5.5
Event History
Frequently Asked Questions
Who is realistically exposed to this issue?
Operators who run the affected iOS image-gathering post module against an attacker-controlled or tampered iOS device are exposed. The resulting write and code execution occur on the operator's workstation, under the operator's account, which may frequently be root.
What must an attacker do to exploit it?
The attacker needs to control file names returned in the Meterpreter directory listing from the iOS device and persuade an operator to run the gather module. A traversal-formatted listing entry can cause files to be written outside the module's intended loot directory.
When does code execution occur?
The initial arbitrary file write occurs when the module processes the hostile directory listing. Persistent code execution can occur on the next msfconsole launch if the attacker overwrites the automatically executed msfconsole.rc file and uses it to load an attacker-written Ruby plugin.