Drupal Database Abstraction API SQLi - Nessus

High   Plugin ID: 78515

This page contains detailed information about the Drupal Database Abstraction API SQLi Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 78515
Name: Drupal Database Abstraction API SQLi
Filename: drupal_7_core_sqli.nasl
Vulnerability Published: 2014-10-15
This Plugin Published: 2014-10-16
Last Modification Time: 2022-04-11
Plugin Version: 1.21
Plugin Type: remote
Plugin Family: CGI abuses
Dependencies: drupal_detect.nasl
Required KB Items [?]: installed_sw/Drupal, www/PHP

Vulnerability Information


Severity: High
Vulnerability Published: 2014-10-15
Patch Published: 2014-10-15
CVE [?]: CVE-2014-3704
CPE [?]: cpe:/a:drupal:drupal

Synopsis

The remote web server is running a PHP application that is affected by a SQL injection vulnerability.

Description

The remote web server is running a version of Drupal that is affected by a SQL injection vulnerability due to a flaw in the Drupal database abstraction API, which allows a remote attacker to use specially crafted requests that can result in arbitrary SQL execution. This may lead to privilege escalation, arbitrary PHP execution, or remote code execution.

Solution

Upgrade to version 7.32 or later.

Public Exploits


Target Network Port(s): 80
Target Asset(s): Services/www
Exploit Available: True (Metasploit Framework, Exploit-DB, GitHub, Immunity Canvas, Core Impact, D2 Elliot)
Exploit Ease: Exploits are available

Here's the list of publicly known exploits and PoCs for verifying the Drupal Database Abstraction API SQLi vulnerability:

  1. Metasploit: exploit/multi/http/drupal_drupageddon
    [Drupal HTTP Parameter Key/Value SQL Injection]
  2. Exploit-DB: exploits/php/webapps/34984.py
    [EDB-34984: Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Injection (PoC) (Reset Password) (1)]
  3. Exploit-DB: exploits/php/webapps/34992.py
    [EDB-34992: Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Injection (Add Admin User)]
  4. Exploit-DB: exploits/php/webapps/34993.php
    [EDB-34993: Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Injection (PoC) (Reset Password) (2)]
  5. Exploit-DB: exploits/php/webapps/35150.php
    [EDB-35150: Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Injection (Remote Code Execution)]
  6. GitHub: https://github.com/0ps/pocassistdb
    [CVE-2014-3704]
  7. GitHub: https://github.com/1120362990/vulnerability-list
    [CVE-2014-3704]
  8. GitHub: https://github.com/AIPOCAI/CVE-2014-3704
    [CVE-2014-3704: PoC for exploiting CVE-2014-3704 : The expandArguments function in the database ...]
  9. GitHub: https://github.com/SexyBeast233/SecBooks
    [CVE-2014-3704]
  10. GitHub: https://github.com/happynote3966/CVE-2014-3704
    [CVE-2014-3704]
  11. GitHub: https://github.com/jweny/pocassistdb
    [CVE-2014-3704]
  12. GitHub: https://github.com/koutto/jok3r-pocs
    [CVE-2014-3704]
  13. GitHub: https://github.com/maya6/-scan-
    [CVE-2014-3704]
  14. GitHub: https://github.com/moradotai/CMS-Scan
    [CVE-2014-3704]
  15. GitHub: https://github.com/vshaliii/DC-1-Vulnhub-Walkthrough
    [CVE-2014-3704]
  16. D2 Elliot: drupal_core_7.x_sql_injection.html
    [Drupal core 7.x SQL Injection]
  17. Immunity Canvas: CANVAS

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 V2 Vector [?]: AV:N/AC:L/Au:N/C:P/I:P/A:P/E:F/RL:OF/RC:C
CVSS Base Score:7.5 (High)
Impact Subscore:6.4
Exploitability Subscore:10.0
CVSS Temporal Score:6.2 (Medium)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:6.2 (Medium)

Go back to menu.

Plugin Source


This is the drupal_7_core_sqli.nasl nessus plugin source code. This script is Copyright (C) 2014-2022 and is owned by Tenable, Inc. or an Affiliate thereof.

#%NASL_MIN_LEVEL 70300
#
# (C) Tenable Network Security, Inc.
#

include('deprecated_nasl_level.inc');
include('compat.inc');

if (description)
{
  script_id(78515);
  script_version("1.21");
  script_set_attribute(attribute:"plugin_modification_date", value:"2022/04/11");

  script_cve_id("CVE-2014-3704");
  script_bugtraq_id(70595);
  script_xref(name:"EDB-ID", value:"34984");
  script_xref(name:"EDB-ID", value:"34992");
  script_xref(name:"EDB-ID", value:"34993");
  script_xref(name:"EDB-ID", value:"35150");

  script_name(english:"Drupal Database Abstraction API SQLi");

  script_set_attribute(attribute:"synopsis", value:
"The remote web server is running a PHP application that is affected by
a SQL injection vulnerability.");
  script_set_attribute(attribute:"description", value:
"The remote web server is running a version of Drupal that is affected
by a SQL injection vulnerability due to a flaw in the Drupal database
abstraction API, which allows a remote attacker to use specially
crafted requests that can result in arbitrary SQL execution. This may
lead to privilege escalation, arbitrary PHP execution, or remote code
execution.");
  script_set_attribute(attribute:"see_also", value:"https://www.drupal.org/SA-CORE-2014-005");
  script_set_attribute(attribute:"see_also", value:"https://www.drupal.org/project/drupal/releases/7.32");
  script_set_attribute(attribute:"solution", value:
"Upgrade to version 7.32 or later.");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:P/I:P/A:P");
  script_set_cvss_temporal_vector("CVSS2#E:F/RL:OF/RC:C");

  script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
  script_set_attribute(attribute:"exploit_available", value:"true");
  script_set_attribute(attribute:"exploit_framework_core", value:"true");
  script_set_attribute(attribute:"d2_elliot_name", value:"Drupal core 7.x SQL Injection");
  script_set_attribute(attribute:"exploit_framework_d2_elliot", value:"true");
  script_set_attribute(attribute:"exploited_by_nessus", value:"true");
  script_set_attribute(attribute:"metasploit_name", value:'Drupal HTTP Parameter Key/Value SQL Injection');
  script_set_attribute(attribute:"exploit_framework_metasploit", value:"true");
  script_set_attribute(attribute:"exploit_framework_canvas", value:"true");
  script_set_attribute(attribute:"canvas_package", value:"CANVAS");

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

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:drupal:drupal");
  script_set_attribute(attribute:"thorough_tests", value:"true");
  script_end_attributes();

  script_category(ACT_ATTACK);
  script_family(english:"CGI abuses");

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

  script_dependencies("drupal_detect.nasl");
  script_require_keys("www/PHP", "installed_sw/Drupal");
  script_require_ports("Services/www", 80);

  exit(0);
}

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

app = "Drupal";
get_install_count(app_name:app, exit_if_zero:TRUE);

port = get_http_port(default:80, php:TRUE);

install = get_single_install(
  app_name : app,
  port     : port
);

dir = install['path'];
url = build_url(qs:dir, port:port);

vuln = FALSE;
time_based = FALSE;

headers = make_array("Content-Type","application/x-www-form-urlencoded");
postdata = "name[0;SELECT+@@version;#]=0;&name[0]=nessus&pass=nessus&test2=" +
  "test&form_build_id=&form_id=user_login_block&op=Log+in";

res = http_send_recv3(
  method : "POST",
  port   : port,
  item   : dir + "/?q=node&destination=node",
  data   : postdata,
  add_headers  : headers,
  exit_on_fail : TRUE
);

if (
  ">Warning</em>: mb_strlen() expects parameter" >< res[2] &&
  "The website encountered an unexpected error." >!< res[2]
)
{
  vuln = TRUE;
  attack_req = http_last_sent_request();
  output = strstr(res[2], ">Warning</em>: mb_strlen()");
}

# Check time based attack for instances where error messages have been
# disabled by the administrator -> https://www.drupal.org/node/244642
if (!vuln && report_paranoia == 2)
{
  stimes = make_list(4, 6, 9);

  for ( i = 0 ; i < max_index(stimes); i ++ )
  {
    http_set_read_timeout(stimes[i] + 10);
    then = unixtime();
    postdata = "name[0;SELECT+sleep(" + stimes[i] + ");#]=&name[0]=nessus" +
      "&pass=fake&test2=test&form_build_id=&form_id=user_login_block&op=Log+in";

    res = http_send_recv3(
      method : "POST",
      port   : port,
      item   : dir + "/?q=node&destination=node",
      data   : postdata,
      add_headers : headers,
      exit_on_fail : TRUE
    );
    now = unixtime();

    ttime = now - then;
    if ( (ttime >= stimes[i]) && (ttime <= (stimes[i] + 5)) )
    {
      vuln = TRUE;
      time_based = TRUE;
      attack_req = http_last_sent_request();
      output = 'The request produced a sleep time of ' + ttime + ' seconds.';
      continue;
    }
    else
      vuln = FALSE;
  }
}

if (!vuln) audit(AUDIT_WEB_APP_NOT_AFFECTED, app, url);

if (time_based)
{
  snip = crap(data:"-", length:30)+' snip '+ crap(data:"-", length:30);
  set_kb_item(name:'www/'+port+'/SQLInjection', value:TRUE);
  if (report_verbosity > 0)
  {
    report =
      '\nNessus was able to exploit the issue using the following request :' +
      '\n' + attack_req + '\n' +
      '\n' + output +
      '\n';
    security_hole(port:port, extra:report);
  }
  else security_hole(port);
  exit(0);
}
else
{
  security_report_v4(
    port       : port,
    severity   : SECURITY_HOLE,
    generic    : TRUE,
    line_limit : 5,
    sqli       : TRUE,  # Sets SQLInjection KB key
    request    : make_list(attack_req),
    output     : chomp(output)
  );
  exit(0);
}

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

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

Go back to menu.

How to Run


Here is how to run the Drupal Database Abstraction API SQLi 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 CGI abuses plugin family.
  6. On the right side table select Drupal Database Abstraction API SQLi plugin ID 78515.
  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 drupal_7_core_sqli.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

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

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

/opt/nessus/bin/nasl -T - drupal_7_core_sqli.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 drupal_7_core_sqli.nasl -t <IP/HOST>

Go back to menu.

References


BID | SecurityFocus Bugtraq ID: See also: Similar and related Nessus plugins:
  • 78518 - Debian DSA-3051-1 : drupal7 - security update
  • 78511 - Drupal 7.x < 7.32 SQLi
  • 78795 - Fedora 21 : drupal7-7.32-1.fc21 (2014-12934)
  • 78707 - Fedora 20 : drupal7-7.32-1.fc20 (2014-13030)
  • 78710 - Fedora 19 : drupal7-7.32-1.fc19 (2014-13053)
  • 78521 - FreeBSD : drupal7 -- SQL injection (6f825fa4-5560-11e4-a4c3-00a0986f28c4)
  • 82456 - Mandriva Linux Security Advisory : drupal (MDVSA-2015:181)
  • 71144 - Drupal 6.x < 6.29 Multiple Vulnerabilities
  • 71145 - Drupal 7.x < 7.24 Multiple Vulnerabilities
  • 79386 - Drupal 6.x < 6.34 / 7.x < 7.34 Multiple Vulnerabilities
  • 92495 - Drupal 8.x < 8.1.7 PHP HTTP_PROXY Environment Variable Namespace Collision Vulnerability (httpoxy)
  • 101063 - Drupal 7.x < 7.56 / 8.x < 8.3.4 Multiple Vulnerabilities (SA-CORE-2017-003)
  • 124176 - Drupal 7.x < 7.66 / 8.5.x < 8.5.15 / 8.6.x < 8.6.15 Multiple Vulnerabilities (drupal-2019-04-17)
  • 108688 - Drupal 7.x < 7.58 / 8.3.x < 8.3.9 / 8.4.x < 8.4.6 / 8.5.x < 8.5.1 Remote Code Execution Vulnerability (SA-CORE-2018-002)
  • 109344 - Drupal 7.x < 7.59 / 8.4.x < 8.4.8 / 8.5.x < 8.5.3 Remote Code Execution Vulnerability (SA-CORE-2018-004)
  • 111599 - Drupal 8.x < 8.5.6 Symfony Risky HTTP Header Restriction Bypass Vulnerability (SA-CORE-2018-005)
  • 122349 - Drupal 8.5.x < 8.5.11 / 8.6.x < 8.6.10 Remote Code Execution (SA-CORE-2019-003)
  • 124698 - Drupal 7.0.x < 7.67 / 8.6.x < 8.6.16 / 8.7.x < 8.7.1 Drupal Vulnerability (SA-CORE-2019-007)
  • 121214 - Drupal 7.x < 7.62 / 8.5.x < 8.5.9 / 8.6.x < 8.6.6 Multiple Vulnerabilities (SA-CORE-2019-001, SA-CORE-2019-002)
  • 136745 - Drupal 7.0.x < 7.70 / 7.0.x < 7.70 / 8.7.x < 8.7.14 / 8.8.x < 8.8.6 Multiple Vulnerabilities (drupal-2020-05-20)
  • 143274 - Drupal 7.x < 7.75 / 8.x < 8.8.12 / 8.9.x < 8.9.10 / 9.0.x < 9.0.9 Multiple Vulnerabilities (SA-CORE-2020-013)
  • 148896 - Drupal 7.x < 7.78 / 8.9.x < 8.9.13 / 9.x < 9.0.11 / 9.1.x < 9.1.3 Directory Traversal (SA-CORE-2021-001)
  • 151932 - Drupal 7.x < 7.82 / 8.9.x < 8.9.17 / 9.1.x < 9.1.11 / 9.2.x < 9.2.2 Drupal Vulnerability (SA-CORE-2021-004)
  • 156863 - Drupal 7.x < 7.86 / 9.2.x < 9.2.11 / 9.3.x < 9.3.3 Multiple Vulnerabilities (drupal-2022-01-19)
  • 24266 - Drupal Comment Module comment_form_add_preview() Function Arbitrary Code Execution
  • 24265 - Drupal Comment Function Arbitrary Code Execution
  • 128551 - Drupal PHPUnit/Mailchimp Code Execution Vulnerability
  • 109041 - Drupal Remote Code Execution Vulnerability (SA-CORE-2018-002) (exploit)
  • 122449 - Drupal Remote Code Execution Vulnerability (SA-CORE-2019-003) (exploit)
  • 18640 - Drupal XML-RPC for PHP Remote Code Injection
  • 123006 - Drupal 7.x < 7.65 / 8.5.x < 8.5.14 / 8.6.x < 8.6.13 XSS (SA-CORE-2019-004)

Version


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

Go back to menu.