Portable SDK for UPnP Devices (libupnp) < 1.6.18 Multiple Stack-based Buffer Overflows RCE - Nessus

Critical   Plugin ID: 64394

This page contains detailed information about the Portable SDK for UPnP Devices (libupnp) < 1.6.18 Multiple Stack-based Buffer Overflows RCE Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 64394
Name: Portable SDK for UPnP Devices (libupnp) < 1.6.18 Multiple Stack-based Buffer Overflows RCE
Filename: libupnp_1_6_18.nasl
Vulnerability Published: 2012-03-08
This Plugin Published: 2013-02-01
Last Modification Time: 2020-03-02
Plugin Version: 1.16
Plugin Type: remote
Plugin Family: Gain a shell remotely
Dependencies: http_version.nasl, upnp_search.nasl

Vulnerability Information


Severity: Critical
Vulnerability Published: 2012-03-08
Patch Published: 2013-01-29
CVE [?]: CVE-2012-5958, CVE-2012-5959, CVE-2012-5960, CVE-2012-5961, CVE-2012-5962, CVE-2012-5963, CVE-2012-5964, CVE-2012-5965
CPE [?]: cpe:/a:libupnp_project:libupnp, cpe:/a:portable_sdk_for_upnp_project:portable_sdk_for_upnp

Synopsis

A network service running on the remote host is affected by multiple remote code execution vulnerabilities.

Description

According to its banner, the version of Portable SDK for UPnP Devices (libupnp) running on the remote host is prior to 1.6.18. It is, therefore, affected by multiple remote code execution vulnerabilities :

- A stack-based buffer overflow condition exists in the unique_service_name() function within file ssdp/ssdp_server.c when handling Simple Service Discovery Protocol (SSDP) requests that is triggered while copying the DeviceType URN. An unauthenticated, remote attacker can exploit this, via a specially crafted SSDP request, to execute arbitrary code. (CVE-2012-5958)

- A stack-based buffer overflow condition exists in the unique_service_name() function within file ssdp/ssdp_server.c when handling Simple Service Discovery Protocol (SSDP) requests that is triggered while copying the UDN prior to two colons. An unauthenticated, remote attacker can exploit this, via a specially crafted SSDP request, to execute arbitrary code. (CVE-2012-5959)

- A stack-based buffer overflow condition exists in the unique_service_name() function within file ssdp/ssdp_server.c when handling Simple Service Discovery Protocol (SSDP) requests that is triggered while copying the UDN prior to the '::upnp:rootdevice' string. An unauthenticated, remote attacker can exploit this, via a specially crafted SSDP request, to execute arbitrary code. (CVE-2012-5960)

- Multiple stack-based buffer overflow conditions exist in the unique_service_name() function within file ssdp/ssdp_server.c due to improper validation of the UDN, DeviceType, and ServiceType fields when parsing Simple Service Discovery Protocol (SSDP) requests. An unauthenticated, remote attacker can exploit these issues, via a specially crafted SSDP request, to execute arbitrary code. (CVE-2012-5961, CVE-2012-5962, CVE-2012-5963, CVE-2012-5964, CVE-2012-5965)

Solution

Upgrade to libupnp version 1.6.18 or later. If libupnp is used as a third party library by a different application, contact the vendor of that application for a fix.

Public Exploits


Target Network Port(s): N/A
Target Asset(s): Services/www, upnp/server
Exploit Available: True (Metasploit Framework, Exploit-DB, GitHub)
Exploit Ease: Exploits are available

Here's the list of publicly known exploits and PoCs for verifying the Portable SDK for UPnP Devices (libupnp) < 1.6.18 Multiple Stack-based Buffer Overflows RCE vulnerability:

  1. Metasploit: exploit/multi/upnp/libupnp_ssdp_overflow
    [Portable UPnP SDK unique_service_name() Remote Code Execution]
  2. Metasploit: auxiliary/scanner/upnp/ssdp_msearch
    [UPnP SSDP M-SEARCH Information Discovery]
  3. Exploit-DB: exploits/linux/dos/49119.py
    [EDB-49119: libupnp 1.6.18 - Stack-based buffer overflow (DoS)]
  4. Exploit-DB: exploits/unix/remote/24455.rb
    [EDB-24455: Portable UPnP SDK - 'unique_service_name()' Remote Code Execution (Metasploit)]
  5. GitHub: https://github.com/lochiiconnectivity/vulnupnp
    [CVE-2012-5958: Discover uPNP devices vulnerable to CVE-2013-0229 / CVE-2013-0230 / CVE-2012-5958 / ...]
  6. GitHub: https://github.com/finn79426/CVE-2012-5960-PoC
    [CVE-2012-5959: CVE-2012-5960, CVE-2012-5959 Proof of Concept]
  7. GitHub: https://github.com/lochiiconnectivity/vulnupnp
    [CVE-2012-5959: Discover uPNP devices vulnerable to CVE-2013-0229 / CVE-2013-0230 / CVE-2012-5958 / ...]
  8. GitHub: https://github.com/finn79426/CVE-2012-5960-PoC
    [CVE-2012-5960: CVE-2012-5960, CVE-2012-5959 Proof of Concept]

Before running any exploit against any system, make sure you are authorized by the owner of the target system(s) to perform such activity. In any other case, this would be considered as an illegal activity.

WARNING: Beware of using unverified exploits from sources such as GitHub or Exploit-DB. These exploits and PoCs could contain malware. For more information, see how to use exploits safely.

Risk Information


CVSS Score Source [?]: CVE-2012-5958
CVSS V2 Vector: AV:N/AC:L/Au:N/C:C/I:C/A:C/E:F/RL:OF/RC:C
CVSS Base Score:10.0 (High)
Impact Subscore:10.0
Exploitability Subscore:10.0
CVSS Temporal Score:8.3 (High)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:8.3 (High)
CVSS V3 Vector: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:F/RL:O/RC:C
CVSS Base Score:9.8 (Critical)
Impact Subscore:5.9
Exploitability Subscore:3.9
CVSS Temporal Score:9.1 (Critical)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:9.1 (Critical)

Go back to menu.

Plugin Source


This is the libupnp_1_6_18.nasl nessus plugin source code. This script is Copyright (C) 2013-2020 Tenable Network Security, Inc.

#
# (C) Tenable Network Security, Inc.
#

include("compat.inc");

if (description)
{
  script_id(64394);
  script_version("1.16");
  script_set_attribute(attribute:"plugin_modification_date", value:"2020/03/02");

  script_cve_id(
    "CVE-2012-5958",
    "CVE-2012-5959",
    "CVE-2012-5960",
    "CVE-2012-5961",
    "CVE-2012-5962",
    "CVE-2012-5963",
    "CVE-2012-5964",
    "CVE-2012-5965"
  );
  script_bugtraq_id(57602);
  script_xref(name:"CERT", value:"922681");
  script_xref(name:"EDB-ID", value:"24455");

  script_name(english:"Portable SDK for UPnP Devices (libupnp) < 1.6.18 Multiple Stack-based Buffer Overflows RCE");
  script_summary(english:"Checks the libupnp banner.");

  script_set_attribute(attribute:"synopsis", value:
"A network service running on the remote host is affected by multiple
remote code execution vulnerabilities.");
  script_set_attribute(attribute:"description", value:
"According to its banner, the version of Portable SDK for UPnP Devices
(libupnp) running on the remote host is prior to 1.6.18. It is,
therefore, affected by multiple remote code execution
vulnerabilities :

  - A stack-based buffer overflow condition exists in the
    unique_service_name() function within file
    ssdp/ssdp_server.c when handling Simple Service
    Discovery Protocol (SSDP) requests that is triggered
    while copying the DeviceType URN. An unauthenticated,
    remote attacker can exploit this, via a specially
    crafted SSDP request, to execute arbitrary code.
    (CVE-2012-5958)

  - A stack-based buffer overflow condition exists in the
    unique_service_name() function within file
    ssdp/ssdp_server.c when handling Simple Service
    Discovery Protocol (SSDP) requests that is triggered
    while copying the UDN prior to two colons. An
    unauthenticated, remote attacker can exploit this, via a
    specially crafted SSDP request, to execute arbitrary
    code. (CVE-2012-5959)

  - A stack-based buffer overflow condition exists in the
    unique_service_name() function within file
    ssdp/ssdp_server.c when handling Simple Service
    Discovery Protocol (SSDP) requests that is triggered
    while copying the UDN prior to the '::upnp:rootdevice'
    string. An unauthenticated, remote attacker can exploit
    this, via a specially crafted SSDP request, to execute
    arbitrary code. (CVE-2012-5960)

  - Multiple stack-based buffer overflow conditions exist in
    the unique_service_name() function within file
    ssdp/ssdp_server.c due to improper validation of the
    UDN, DeviceType, and ServiceType fields when parsing
    Simple Service Discovery Protocol (SSDP) requests. An
    unauthenticated, remote attacker can exploit these
    issues, via a specially crafted SSDP request, to execute
    arbitrary code. (CVE-2012-5961, CVE-2012-5962,
    CVE-2012-5963, CVE-2012-5964, CVE-2012-5965)");
  # https://blog.rapid7.com/2013/01/29/security-flaws-in-universal-plug-and-play-unplug-dont-play/
  script_set_attribute(attribute:"see_also", value:"http://www.nessus.org/u?46d66d2f");
  script_set_attribute(attribute:"see_also", value:"https://help.rapid7.com/?community");
  # https://help.rapid7.com/?community
  script_set_attribute(attribute:"see_also", value:"http://www.nessus.org/u?d381943f");
  # https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20130129-upnp
  script_set_attribute(attribute:"see_also", value:"http://www.nessus.org/u?8642ada6");
  # https://cert-portal.siemens.com/productcert/pdf/ssa-963338.pdf
  script_set_attribute(attribute:"see_also", value:"http://www.nessus.org/u?a76191f3");
  
  script_set_attribute(attribute:"solution", value:
"Upgrade to libupnp version 1.6.18 or later. If libupnp is used as a
third party library by a different application, contact the vendor of
that application for a fix.");
  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:F/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:F/RL:O/RC:C");
  script_set_attribute(attribute:"cvss_score_source", value:"CVE-2012-5958");
  script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
  script_set_attribute(attribute:"exploit_available", value:"true");
  script_set_attribute(attribute:"metasploit_name", value:'Portable UPnP SDK unique_service_name() Remote Code Execution');
  script_set_attribute(attribute:"exploit_framework_metasploit", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"2012/03/08");
  script_set_attribute(attribute:"patch_publication_date", value:"2013/01/29");
  script_set_attribute(attribute:"plugin_publication_date", value:"2013/02/01");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:libupnp_project:libupnp");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:portable_sdk_for_upnp_project:portable_sdk_for_upnp");
  script_end_attributes();

  script_category(ACT_GATHER_INFO);
  script_family(english:"Gain a shell remotely");

  script_copyright(english:"This script is Copyright (C) 2013-2020 Tenable Network Security, Inc.");

  script_dependencies("upnp_search.nasl", "http_version.nasl");
  script_require_ports("upnp/server", "Services/www");

  exit(0);
}

include("audit.inc");
include("global_settings.inc");
include("misc_func.inc");
include("http.inc");

global_var fix, vuln;
fix = '1.6.18';
vuln = FALSE;

##
# Checks if the given server banner is from a vulnerable
# version of libupnp.  If so, a reporting function is
# called
#
# @param port port number of the service being tested
# @param server server banner advertised on "port"
# @param proto the protocol the port is accessible by (tcp or udp)
##
function _check_libupnp_version(port, server, proto)
{
  local_var ver, report, banner;
  server = chomp(server);
  ver = pregmatch(string:server, pattern:' (Intel|Portable|WindRiver) SDK for UPnP devices */([0-9.]+)', icase:TRUE);

  # the latter two checks are there to account for one-offs where there is no version listed
  # in the server banner, but these specific versions are listed as vulnerable in R7's report
  if (
    (!isnull(ver) && ver_compare(ver:ver[2], fix:fix, strict:FALSE) < 0) ||
    server == 'PACKAGE_VERSION  WIND version 2.8, UPnP/1.0, WindRiver SDK for UPnP devices/' ||
    server == 'Linux/2.6.22.19-40-sigma, UPnP/1.0, Portable SDK for UPnP devices/'
  )
  {
    vuln = TRUE;

    banner = preg_replace(string:server, pattern:'SERVER: *(.+)', replace:"\1", icase:TRUE);
    report = '\n  Server banner : ' + banner;
    report += '\n  Source: ' + toupper(proto);
    if (!isnull(ver[2])) report += '\n  Installed version : ' + ver[2];
    report += '\n  Fixed version : ' + fix + '\n';

    security_report_v4(port:port,
                       proto:proto,
                       severity:SECURITY_HOLE,
                       extra:report);
  }
}

# check the server string retrieved via UDP 1900 by upnp_search.nasl
servers = get_kb_list('upnp/server');
foreach (server in servers) _check_libupnp_version(port:1900, server:server, proto:'udp');

# check any server strings retrieved via HTTP and there are any UPnP ports open
www_ports = get_kb_list('Services/www');
if (!isnull(servers))
{
  foreach port (www_ports)
  {
    server = http_server_header(port:port);
    if (isnull(server)) continue;

    _check_libupnp_version(port:port, server:server, proto:'tcp');
  }
}

if (!vuln)
  audit(AUDIT_HOST_NOT, 'affected');

The latest version of this script can be found in these locations depending on your platform:

  • Linux / Unix:
    /opt/nessus/lib/nessus/plugins/libupnp_1_6_18.nasl
  • Windows:
    C:\ProgramData\Tenable\Nessus\nessus\plugins\libupnp_1_6_18.nasl
  • Mac OS X:
    /Library/Nessus/run/lib/nessus/plugins/libupnp_1_6_18.nasl

Go back to menu.

How to Run


Here is how to run the Portable SDK for UPnP Devices (libupnp) < 1.6.18 Multiple Stack-based Buffer Overflows RCE as a standalone plugin via the Nessus web user interface (https://localhost:8834/):

  1. Click to start a New Scan.
  2. Select Advanced Scan.
  3. Navigate to the Plugins tab.
  4. On the top right corner click to Disable All plugins.
  5. On the left side table select Gain a shell remotely plugin family.
  6. On the right side table select Portable SDK for UPnP Devices (libupnp) < 1.6.18 Multiple Stack-based Buffer Overflows RCE plugin ID 64394.
  7. Specify the target on the Settings tab and click to Save the scan.
  8. Run the scan.

Here are a few examples of how to run the plugin in the command line. Note that the examples below demonstrate the usage on the Linux / Unix platform.

Basic usage:

/opt/nessus/bin/nasl libupnp_1_6_18.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

/opt/nessus/bin/nasl -a libupnp_1_6_18.nasl -t <IP/HOST>

Run the plugin with trace script execution written to the console (useful for debugging):

/opt/nessus/bin/nasl -T - libupnp_1_6_18.nasl -t <IP/HOST>

Run the plugin with using a state file for the target and updating it (useful for running multiple plugins on the target):

/opt/nessus/bin/nasl -K /tmp/state libupnp_1_6_18.nasl -t <IP/HOST>

Go back to menu.

References


BID | SecurityFocus Bugtraq ID: CERT | Computer Emergency Response Team: See also: Similar and related Nessus plugins:
  • 64395 - Debian DSA-2614-1 : libupnp - several vulnerabilities
  • 64396 - Debian DSA-2615-1 : libupnp4 - several vulnerabilities
  • 64597 - Fedora 16 : libupnp-1.6.18-1.fc16 (2013-1713)
  • 64600 - Fedora 17 : libupnp-1.6.18-1.fc17 (2013-1734)
  • 64601 - Fedora 18 : libupnp-1.6.18-1.fc18 (2013-1765)
  • 64735 - Fedora 17 : mediatomb-0.12.1-23.fc17 (2013-2352)
  • 64736 - Fedora 18 : mediatomb-0.12.1-23.fc18 (2013-2377)
  • 64374 - FreeBSD : upnp -- multiple vulnerabilities (2ea6ce3d-6afd-11e2-9d4e-bcaec524bf84)
  • 73219 - GLSA-201403-06 : libupnp: Arbitrary code execution
  • 66110 - Mandriva Linux Security Advisory : libupnp (MDVSA-2013:098)
  • 75214 - openSUSE Security Update : libupnp (openSUSE-SU-2013:0255-1)
  • 93221 - Portable SDK for UPnP Devices (libupnp) HTTP Arbitrary File Write
  • 64245 - Portable phpMyAdmin Plugin for WordPress 'wp-pma-mod' Authentication Bypass
  • 118678 - F5 Networks BIG-IP : Apache Portable Runtime vulnerability (K52319810)
  • 74066 - GLSA-201405-24 : Apache Portable Runtime, APR Utility Library: Denial of Service
  • 93017 - Debian DLA-597-1 : libupnp security update
  • 96008 - Debian DLA-747-1 : libupnp security update
  • 96015 - Debian DSA-3736-1 : libupnp - security update
  • 101590 - Fedora 26 : libupnp (2017-23535a31f8)
  • 97674 - Fedora 25 : libupnp (2017-2c29702300)
  • 97702 - Fedora 24 : libupnp (2017-3bd0b2e2c0)
  • 96687 - GLSA-201701-52 : libupnp: Multiple vulnerabilities
  • 100612 - openSUSE Security Update : libupnp (openSUSE-2017-650)
  • 96009 - Debian DLA-748-1 : libupnp4 security update
  • 55907 - HP iNode Management Center Buffer Overflow (HPSB3C02687) (remote check)
  • 69424 - HP LoadRunner < 11.52 SSL Connection Handling Stack Buffer Overflow RCE
  • 24327 - Mercury LoadRunner Agent server_ip_name Field Remote Buffer Overflow
  • 26067 - Mercury IMAP Server SEARCH Command Remote Buffer Overflow
  • 17326 - Sentinel License Manager lservnt Service Remote Buffer Overflow
  • 25935 - SIDVault < 2.0f LDAP Server Malformed Search Request Buffer Overflow
  • 57462 - FreeBSD 'telnetd' Daemon Remote Buffer Overflow
  • 54943 - IBM Tivoli Directory Server SASL Bind Request Buffer Overflow (uncredentialed check)
  • 57765 - Trend Micro Control Manager CmdProcessor.exe Remote Buffer Overflow (uncredentialed check)
  • 40862 - Wyse Thin Client hagent.exe Unspecified Buffer Overflow

Version


This page has been produced using Nessus Professional 10.1.2 (#68) LINUX, Plugin set 202205072148.
Plugin file libupnp_1_6_18.nasl version 1.16. For more plugins, visit the Nessus Plugin Library.

Go back to menu.