SSLv3 Padding Oracle On Downgraded Legacy Encryption Vulnerability (POODLE)

2014-10-15T00:00:00
ID SSL_POODLE.NASL
Type nessus
Reporter This script is Copyright (C) 2014-2020 and is owned by Tenable, Inc. or an Affiliate thereof.
Modified 2014-10-15T00:00:00

Description

The remote host is affected by a man-in-the-middle (MitM) information disclosure vulnerability known as POODLE. The vulnerability is due to the way SSL 3.0 handles padding bytes when decrypting messages encrypted using block ciphers in cipher block chaining (CBC) mode. MitM attackers can decrypt a selected byte of a cipher text in as few as 256 tries if they are able to force a victim application to repeatedly send the same data over newly created SSL 3.0 connections.

As long as a client and service both support SSLv3, a connection can be 'rolled back' to SSLv3, even if TLSv1 or newer is supported by the client and service.

The TLS Fallback SCSV mechanism prevents 'version rollback' attacks without impacting legacy clients; however, it can only protect connections when the client and service support the mechanism. Sites that cannot disable SSLv3 immediately should enable this mechanism.

This is a vulnerability in the SSLv3 specification, not in any particular SSL implementation. Disabling SSLv3 is the only way to completely mitigate the vulnerability.

                                        
                                            #TRUSTED 75056e42da04af0550e1aeb8ff733da2059a39e0ac0f21040f98211cc22d742247869ef3d21fd935fd2db3c3c2dcd63ab2d1906272842c5cd718ba61e86f031052386683f6c5444eada48cda127d574138522ff6b70f322f79654c9a8ddeb38b13252948a2c15207c854f981e2c489ef5231674a41f73b450fe9f997e70bc47efcf1a12eaee3daac519456d39400e62624000861fbe6d0d7449b99f726ac4bcd65697997aaba50b322b0287466759b62324a95633e3160c951539c1d3d80c681da9123bf9b7a9a7cdf78a3d06df945979e5f4142dc936e227f45ebce8514d7fe66697d4a7ecf9bffac4ef085ecbd6353567d80707998ad4de58ac80e84b1a26a14d6d82b3760ce243b061d742f733eb9fdb84f16d540ce599ff1d60ff25d5e038a821917475564cc14fff7feae9288601303fa9f3a3404d703a192d25b8e17efc793a9d7e72f3539733c500ba833f85fc5a3d507bd77afdaa637cafa86eb3eb6e2c36f0abb7858a9febcefa899ecd1d4cd285b3accf2e3e4e9551ab96dc18d18216d4041954ce6576e635540dee547d8ef2797fa51ac6153eefdb0fb4105997303820a764c6f12c7d687301a94b0c916a75ebb68260135ab23c188d3b6a76139a900eb5f788ec12cb1eef6078e94d4fa1fec33b9d2e11edc7e0b21f6721f8576e74f269da980da1d68f8893cf84d099c71c1c614195964daee41a7c5438c032c
#
# (C) Tenable Network Security, Inc.
#

include("compat.inc");

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

  script_cve_id("CVE-2014-3566");
  script_bugtraq_id(70574);
  script_xref(name:"CERT", value:"577193");

  script_name(english:"SSLv3 Padding Oracle On Downgraded Legacy Encryption Vulnerability (POODLE)");
  script_summary(english:"Checks if SSL/TLS server supports SSLv3 and TLS Fallback SCSV.");

  script_set_attribute(attribute:"synopsis", value:
"It is possible to obtain sensitive information from the remote host
with SSL/TLS-enabled services.");
  script_set_attribute(attribute:"description", value:
"The remote host is affected by a man-in-the-middle (MitM) information
disclosure vulnerability known as POODLE. The vulnerability is due to
the way SSL 3.0 handles padding bytes when decrypting messages
encrypted using block ciphers in cipher block chaining (CBC) mode.
MitM attackers can decrypt a selected byte of a cipher text in as few
as 256 tries if they are able to force a victim application to
repeatedly send the same data over newly created SSL 3.0 connections.

As long as a client and service both support SSLv3, a connection can
be 'rolled back' to SSLv3, even if TLSv1 or newer is supported by the
client and service.

The TLS Fallback SCSV mechanism prevents 'version rollback' attacks
without impacting legacy clients; however, it can only protect
connections when the client and service support the mechanism. Sites
that cannot disable SSLv3 immediately should enable this mechanism.

This is a vulnerability in the SSLv3 specification, not in any
particular SSL implementation. Disabling SSLv3 is the only way to
completely mitigate the vulnerability.");
  script_set_attribute(attribute:"see_also", value:"https://www.imperialviolet.org/2014/10/14/poodle.html");
  script_set_attribute(attribute:"see_also", value:"https://www.openssl.org/~bodo/ssl-poodle.pdf");
  script_set_attribute(attribute:"see_also", value:"https://tools.ietf.org/html/draft-ietf-tls-downgrade-scsv-00");
  script_set_attribute(attribute:"solution", value:
"Disable SSLv3.

Services that must support SSLv3 should enable the TLS Fallback SCSV
mechanism until SSLv3 can be disabled.");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:M/Au:N/C:P/I:N/A:N");
  script_set_cvss_temporal_vector("CVSS2#E:U/RL:OF/RC:C");
  script_set_cvss3_base_vector("CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N");
  script_set_cvss3_temporal_vector("CVSS:3.0/E:U/RL:O/RC:C");
  script_set_attribute(attribute:"cvss_score_source", value:"CVE-2014-3566");

  script_set_attribute(attribute:"exploitability_ease", value:"No known exploits are available");
  script_set_attribute(attribute:"exploit_available", value:"false");
  script_set_attribute(attribute:"in_the_news", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"2014/10/14");
  script_set_attribute(attribute:"plugin_publication_date", value:"2014/10/15");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_end_attributes();

  script_category(ACT_GATHER_INFO);
  script_family(english:"General");

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

  script_dependencies("ssl_supported_versions.nasl", "ssl_supported_ciphers.nasl");
  script_require_keys("SSL/Supported");

  exit(0);
}

include("ftp_func.inc");
include("global_settings.inc");
include("ldap_func.inc");
include("nntp_func.inc");
include("rsync.inc");
include("smtp_func.inc");
include("telnet2_func.inc");
include("x509_func.inc");
include("audit.inc");

connection_reset = FALSE;
# Send an SSLv3 ClientHello with modified cipher suite list.
# Cipher suite list must be in the format that client_hello expects.
function send_recv_client_hello(port, cipherspec)
{
  local_var soc, rec, chello;

  soc = open_sock_ssl(port);
  if (!soc) return NULL;

  chello = client_hello(
    version:mkword(SSL_V3),
    v2hello:FALSE,
    cipherspec:cipherspec
  );
  send(socket:soc, data:chello);
  rec = recv_ssl(socket:soc, partial:TRUE);
  if (socket_get_error(soc) == ECONNRESET)
    connection_reset = TRUE;
  close(soc);

  return rec;
}

function check_fallback_scsv(port, cipherspec)
{
  local_var rec, cipher_name, kb_key;

  # Add the TLS_FALLBACK_SCSV to the list
  cipherspec += raw_string(0x56, 0x00);

  rec = send_recv_client_hello(port:port, cipherspec:cipherspec);

  # If the server resets the connection, we consider the mitigation to be
  # applied. It's not technically following the spec (supposed to send an
  # alert), but functionally it's the same.
  # It appears Citrix Netscaler devices do this.
  if (connection_reset == TRUE && isnull(rec))
    return TRUE;

  rec = ssl_parse(blob:rec);
  if (isnull(rec))
    return "no-record";

  if (rec["content_type"] == SSL3_CONTENT_TYPE_ALERT &&
      rec["level"]        == SSL3_ALERT_TYPE_FATAL &&
      rec["description"]  == SSL3_ALERT_TYPE_INAPPROPRIATE_FALLBACK)
  {
    return TRUE;
  }

  # Server responded with something that's not an INAPPROPRIATE_FALLBACK alert.
  # Probably a ServerHello. If not, something is wrong so bail.
  if (rec["content_type"]   == SSL3_CONTENT_TYPE_HANDSHAKE &&
      rec["handshake_type"] == SSL3_HANDSHAKE_TYPE_SERVER_HELLO)
  {
    return FALSE;
  }

  kb_key = "ssl_poodle_fallback_scsv_test_returned";
  if (rec["content_type"] == SSL3_CONTENT_TYPE_HANDSHAKE)
    set_kb_item(name:kb_key, value:"handshake:" + rec["handshake_type"]);
  else if (rec["content_type"] == SSL3_CONTENT_TYPE_ALERT)
    set_kb_item(name:kb_key, value:"alert:" + rec["level"] + ":" + rec["description"]);
  else
    set_kb_item(name:kb_key, value:"content_type:" + rec["content_type"]);

  return "error";
}

port = get_ssl_ports(fork:TRUE);
if (isnull(port)) exit(0, "This host has no SSL/TLS services.");
if (!get_port_state(port)) audit(AUDIT_PORT_CLOSED, port);

# Check if SSLv3 and if some form of TLS is supported
versions = make_list(get_kb_list_or_exit("SSL/Transport/" + port));
ssl3_supported = FALSE;
tls_supported = FALSE;
foreach version (versions)
{
  if (version == ENCAPS_SSLv3)
    ssl3_supported = TRUE;

  if (version >= ENCAPS_TLSv1)
    tls_supported = TRUE;
}
if (!ssl3_supported)
  exit(0, "The service on port " + port + " does not support SSLv3.");

cbc_supported = FALSE;
cipherspec = "";
foreach cipher_name (get_kb_list_or_exit("SSL/Ciphers/" + port))
{
  if (cipher_name !~ "^TLS1[12]?_")
    continue;

  if ("_CBC_" >!< cipher_name)
    continue;

  cbc_supported = TRUE;
  cipherspec += ciphers[cipher_name];
}

if (!cbc_supported)
  exit(0, "The service on port " + port + " supports SSLv3 but not any CBC cipher suites.");

# If the server supports only SSLv3 (nothing newer, like TLSv1.1) then
# there is no way to detect the TLS_FALLBACK_SCSV in action.
fallback_scsv_supported = FALSE;
if (tls_supported)
  fallback_scsv_supported = check_fallback_scsv(port:port, cipherspec:cipherspec);

if (fallback_scsv_supported == TRUE)
  exit(0, "The service on port " + port + " supports SSLv3 with CBC ciphers, but the Fallback SCSV mechanism is enabled.");

if (fallback_scsv_supported == "no-record")
  exit(0, "The service on port " + port + " supports SSLv3 with CBC ciphers, and the server did not reply while determining Fallback SCSV support.");

if (fallback_scsv_supported == "error")
  exit(0, "The service on port " + port + " supports SSLv3 with CBC ciphers, and support for Fallback SCSV could not be determined.");

report = NULL;
if (report_verbosity > 0)
{
  report =
    '\n' + 'Nessus determined that the remote server supports SSLv3 with at least one CBC ' +
    '\n' + 'cipher suite, indicating that this server is vulnerable.\n';

  if (!tls_supported)
  {
    report +=
      '\n' + 'It appears that TLSv1 or newer is not supported on the server. Mitigating this ' +
      '\n' + 'vulnerability requires SSLv3 to be disabled and TLSv1 or newer to be enabled.';
  }
  else
  {
    # We only get here if TLS is supported *and* Fallback SCSV is not enabled.
    report +=
      '\n' + 'It appears that TLSv1 or newer is supported on the server. However, the ' +
      '\n' + 'Fallback SCSV mechanism is not supported, allowing connections to be "rolled ' +
      '\n' + 'back" to SSLv3.';
  }

  report += '\n';
}
set_kb_item(name:"SSL/vulnerable_to_poodle/"+port, value:TRUE);
security_warning(port:port, extra:report);