Vulnerabilities > CVE-2009-1151 - Code Injection vulnerability in multiple products
Attack vector
NETWORK Attack complexity
LOW Privileges required
NONE Confidentiality impact
HIGH Integrity impact
HIGH Availability impact
HIGH Summary
Static code injection vulnerability in setup.php in phpMyAdmin 2.11.x before 2.11.9.5 and 3.x before 3.1.3.1 allows remote attackers to inject arbitrary PHP code into a configuration file via the save action.
Vulnerable Configurations
Common Weakness Enumeration (CWE)
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.
D2sec
name | Phpmyadmin File Upload |
url | http://www.d2sec.com/exploits/phpmyadmin_file_upload.html |
Exploit-Db
description phpMyAdmin (/scripts/setup.php) PHP Code Injection Exploit. CVE-2009-1151. Webapps exploit for php platform file exploits/php/webapps/8921.sh id EDB-ID:8921 last seen 2016-02-01 modified 2009-06-09 platform php port published 2009-06-09 reporter Adrian "pagvac" Pastor source https://www.exploit-db.com/download/8921/ title phpMyAdmin /scripts/setup.php PHP Code Injection Exploit type webapps description PhpMyAdmin Config File Code Injection. CVE-2009-1151. Webapps exploit for php platform id EDB-ID:16913 last seen 2016-02-02 modified 2010-07-03 published 2010-07-03 reporter metasploit source https://www.exploit-db.com/download/16913/ title PhpMyAdmin Config File Code Injection description pmaPWN! - phpMyAdmin Code Injection RCE Scanner & Exploit. CVE-2009-1151. Webapps exploit for php platform id EDB-ID:8992 last seen 2016-02-01 modified 2009-06-22 published 2009-06-22 reporter Hacking Expose! source https://www.exploit-db.com/download/8992/ title pmaPWN! - phpMyAdmin Code Injection RCE Scanner & Exploit
Metasploit
description | This module exploits a vulnerability in phpMyAdmin's setup feature which allows an attacker to inject arbitrary PHP code into a configuration file. The original advisory says the vulnerability is present in phpMyAdmin versions 2.11.x < 2.11.9.5 and 3.x < 3.1.3.1; this module was tested on 3.0.1.1. The file where our payload is written (phpMyAdmin/config/config.inc.php) is not directly used by the system, so it may be a good idea to either delete it or copy the running config (phpMyAdmin/config.inc.php) over it after successful exploitation. |
id | MSF:EXPLOIT/UNIX/WEBAPP/PHPMYADMIN_CONFIG |
last seen | 2020-02-09 |
modified | 2017-09-08 |
published | 2009-11-16 |
references | |
reporter | Rapid7 |
source | https://github.com/rapid7/metasploit-framework/blob/master//modules/exploits/unix/webapp/phpmyadmin_config.rb |
title | PhpMyAdmin Config File Code Injection |
Nessus
NASL family CGI abuses NASL id PHPMYADMIN_PMASA_2009_3.NASL description The setup script included with the version of phpMyAdmin installed on the remote host does not properly sanitize user-supplied input to several variables before using them to generate a config file for the application. Using specially crafted POST requests, an unauthenticated, remote attacker may be able to leverage this issue to execute arbitrary PHP code. Note that the application is also reportedly affected by several other issues, although Nessus has not actually checked for them. last seen 2020-06-01 modified 2020-06-02 plugin id 36170 published 2009-04-16 reporter This script is Copyright (C) 2009-2018 Tenable Network Security, Inc. source https://www.tenable.com/plugins/nessus/36170 title phpMyAdmin setup.php save Action Arbitrary PHP Code Injection (PMASA-2009-3) code # # (C) Tenable Network Security, Inc. # include("compat.inc"); if (description) { script_id(36170); script_version("1.22"); script_cvs_date("Date: 2018/07/24 18:56:11"); script_cve_id("CVE-2009-1151"); script_bugtraq_id(34236); script_xref(name:"Secunia", value:"34430"); script_name(english:"phpMyAdmin setup.php save Action Arbitrary PHP Code Injection (PMASA-2009-3)"); script_summary(english:"Tries to inject PHP code into temporary config file"); script_set_attribute( attribute:"synopsis", value: "The remote web server contains a PHP application that may allow execution of arbitrary code." ); script_set_attribute( attribute:"description", value: "The setup script included with the version of phpMyAdmin installed on the remote host does not properly sanitize user-supplied input to several variables before using them to generate a config file for the application. Using specially crafted POST requests, an unauthenticated, remote attacker may be able to leverage this issue to execute arbitrary PHP code. Note that the application is also reportedly affected by several other issues, although Nessus has not actually checked for them."); script_set_attribute( attribute:"see_also", value:"http://www.phpmyadmin.net/home_page/security/PMASA-2009-3.php" ); script_set_attribute( attribute:"solution", value: "Upgrade to phpMyAdmin 2.11.9.5 / 3.1.3.1 or apply the patch referenced in the project's advisory." ); 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_attribute(attribute:"exploitability_ease", value:"No exploit is required"); script_set_attribute(attribute:"exploit_available", value:"false"); script_set_attribute(attribute:"exploit_framework_core", value:"true"); script_set_attribute(attribute:"d2_elliot_name", value:"Phpmyadmin File Upload"); script_set_attribute(attribute:"exploit_framework_d2_elliot", value:"true"); script_set_attribute(attribute:"exploited_by_malware", value:"true"); script_set_attribute(attribute:"metasploit_name", value:'PhpMyAdmin Config File Code 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_cwe_id(94); script_set_attribute(attribute:"plugin_publication_date", value: "2009/04/16"); 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) 2009-2018 Tenable Network Security, Inc."); script_dependencies("phpMyAdmin_detect.nasl"); script_exclude_keys("Settings/disable_cgi_scanning"); script_require_ports("Services/www", 80); script_require_keys("www/phpMyAdmin", "www/PHP"); exit(0); } include("global_settings.inc"); include("misc_func.inc"); include("http.inc"); include("url_func.inc"); port = get_http_port(default:80, embedded:FALSE, php:TRUE); # Define some variables. key = string(SCRIPT_NAME, "']; system(id); #"); val = 'NESSUS'; eoltype = "unix"; # Test an install. install = get_kb_item(string("www/", port, "/phpMyAdmin")); if (isnull(install)) exit(0); matches = eregmatch(string:install, pattern:"^(.+) under (/.*)$"); if (!isnull(matches)) { dir = matches[2]; # nb: phpMyAdmin 3.x has its setup script in a different location. We're not # testing it because we don't believe the vulnerability is exploitable in # that version. foreach script (make_list("/scripts/setup.php")) { url = string(dir, script); clear_cookiejar(); res = http_send_recv3(method:"GET", item:url, port:port, exit_on_fail:TRUE); # If the config can't be written to disk, this cannot be exploited - even # if the software is unpatched. In which case, only continue if paranoid. if ('Can not load or save configuration' >< res[2]) { if (report_paranoia < 2) exit(1, "The system might be unpatched, but cannot be exploited."); else config_writeable = FALSE; } else config_writeable = TRUE; # Extract the token. token = NULL; pat = 'input type="hidden" name="token" value="([^"]+)"'; matches = egrep(string:res[2], pattern:pat); if (matches) { foreach match (split(matches, keep:FALSE)) { item = eregmatch(pattern:pat, string:match); if (!isnull(item)) { token = item[1]; break; } } } if (isnull(token)) continue; # Try to exploit the issue. # # nb: we verify the vulnerability only by displaying the config file; # if the config file is not writable, this will produce a result # even though the vulnerability is not really exploitable. configuration = string( 'a:1:{', 's:7:"Servers";a:1:{', 'i:0;a:1:{', 's:', strlen(key), ':"', key, '";', 's:', strlen(val), ':"', val, '";', '}', '}', '}' ); postdata = string( "token=", token, "&", "action=display&", "configuration=", urlencode(str:configuration), "&", "eoltype=", eoltype ); req = http_mk_post_req( port : port, item : url, data : postdata, add_headers : make_array( "Content-Type", "application/x-www-form-urlencoded" ) ); res = http_send_recv_req(port:port, req:req, exit_on_fail:TRUE); # There's a problem if our key was accepted. if (string("$cfg['Servers'][$i]['", key, "'] = '", val, "';") >< res[2]) { if (!config_writeable) { report = string( "\n", "Even though the software is unpatched, the web server does not\n", "have permission to write the configuration file to disk, which\n", "means the vulnerability cannot be exploited at this time.\n" ); security_hole(port:port, extra:report); } else security_hole(port); } } }
NASL family SuSE Local Security Checks NASL id SUSE_11_0_PHPMYADMIN-090401.NASL description This update of phpMyAdmin fixes multiple vulnerabilities : - CVE-2009-1148: directory traversal - CVE-2009-1149: CRLF injection - CVE-2009-1150: cross-site scripting - CVE-2009-1151: static code injection last seen 2020-06-01 modified 2020-06-02 plugin id 40108 published 2009-07-21 reporter This script is Copyright (C) 2009-2019 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/40108 title openSUSE Security Update : phpMyAdmin (phpMyAdmin-711) code #%NASL_MIN_LEVEL 80502 # # (C) Tenable Network Security, Inc. # # The descriptive text and package checks in this plugin were # extracted from openSUSE Security Update phpMyAdmin-711. # # The text description of this plugin is (C) SUSE LLC. # include("compat.inc"); if (description) { script_id(40108); script_version("1.17"); script_cvs_date("Date: 2019/10/25 13:36:34"); script_cve_id("CVE-2009-1148", "CVE-2009-1149", "CVE-2009-1150", "CVE-2009-1151"); script_name(english:"openSUSE Security Update : phpMyAdmin (phpMyAdmin-711)"); script_summary(english:"Check for the phpMyAdmin-711 patch"); script_set_attribute( attribute:"synopsis", value:"The remote openSUSE host is missing a security update." ); script_set_attribute( attribute:"description", value: "This update of phpMyAdmin fixes multiple vulnerabilities : - CVE-2009-1148: directory traversal - CVE-2009-1149: CRLF injection - CVE-2009-1150: cross-site scripting - CVE-2009-1151: static code injection" ); script_set_attribute( attribute:"see_also", value:"https://bugzilla.novell.com/show_bug.cgi?id=490596" ); script_set_attribute( attribute:"solution", value:"Update the affected phpMyAdmin package." ); script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:P/I:P/A:P"); 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:"Phpmyadmin File Upload"); script_set_attribute(attribute:"exploit_framework_d2_elliot", value:"true"); script_set_attribute(attribute:"exploited_by_malware", value:"true"); script_set_attribute(attribute:"metasploit_name", value:'PhpMyAdmin Config File Code 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_cwe_id(20, 22, 79, 94); script_set_attribute(attribute:"plugin_type", value:"local"); script_set_attribute(attribute:"cpe", value:"p-cpe:/a:novell:opensuse:phpMyAdmin"); script_set_attribute(attribute:"cpe", value:"cpe:/o:novell:opensuse:11.0"); script_set_attribute(attribute:"vuln_publication_date", value:"2009/03/26"); script_set_attribute(attribute:"patch_publication_date", value:"2009/04/01"); script_set_attribute(attribute:"plugin_publication_date", value:"2009/07/21"); script_set_attribute(attribute:"generated_plugin", value:"current"); script_end_attributes(); script_category(ACT_GATHER_INFO); script_copyright(english:"This script is Copyright (C) 2009-2019 and is owned by Tenable, Inc. or an Affiliate thereof."); script_family(english:"SuSE Local Security Checks"); script_dependencies("ssh_get_info.nasl"); script_require_keys("Host/local_checks_enabled", "Host/SuSE/release", "Host/SuSE/rpm-list"); exit(0); } include("audit.inc"); include("global_settings.inc"); include("rpm.inc"); if (!get_kb_item("Host/local_checks_enabled")) audit(AUDIT_LOCAL_CHECKS_NOT_ENABLED); release = get_kb_item("Host/SuSE/release"); if (isnull(release) || release =~ "^(SLED|SLES)") audit(AUDIT_OS_NOT, "openSUSE"); if (release !~ "^(SUSE11\.0)$") audit(AUDIT_OS_RELEASE_NOT, "openSUSE", "11.0", release); if (!get_kb_item("Host/SuSE/rpm-list")) audit(AUDIT_PACKAGE_LIST_MISSING); flag = 0; if ( rpm_check(release:"SUSE11.0", reference:"phpMyAdmin-2.11.9.5-0.1") ) flag++; if (flag) { if (report_verbosity > 0) security_hole(port:0, extra:rpm_report_get()); else security_hole(0); exit(0); } else { tested = pkg_tests_get(); if (tested) audit(AUDIT_PACKAGE_NOT_AFFECTED, tested); else audit(AUDIT_PACKAGE_NOT_INSTALLED, "phpMyAdmin"); }
NASL family Gentoo Local Security Checks NASL id GENTOO_GLSA-200906-03.NASL description The remote host is affected by the vulnerability described in GLSA-200906-03 (phpMyAdmin: Multiple vulnerabilities) Multiple vulnerabilities have been reported in phpMyAdmin: Greg Ose discovered that the setup script does not sanitize input properly, leading to the injection of arbitrary PHP code into the configuration file (CVE-2009-1151). Manuel Lopez Gallego and Santiago Rodriguez Collazo reported that data from cookies used in the last seen 2020-06-01 modified 2020-06-02 plugin id 39570 published 2009-06-30 reporter This script is Copyright (C) 2009-2019 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/39570 title GLSA-200906-03 : phpMyAdmin: Multiple vulnerabilities code #%NASL_MIN_LEVEL 80502 # # (C) Tenable Network Security, Inc. # # The descriptive text and package checks in this plugin were # extracted from Gentoo Linux Security Advisory GLSA 200906-03. # # The advisory text is Copyright (C) 2001-2019 Gentoo Foundation, Inc. # and licensed under the Creative Commons - Attribution / Share Alike # license. See http://creativecommons.org/licenses/by-sa/3.0/ # include("compat.inc"); if (description) { script_id(39570); script_version("1.22"); script_cvs_date("Date: 2019/08/02 13:32:45"); script_cve_id("CVE-2009-1150", "CVE-2009-1151"); script_bugtraq_id(34251); script_xref(name:"GLSA", value:"200906-03"); script_name(english:"GLSA-200906-03 : phpMyAdmin: Multiple vulnerabilities"); script_summary(english:"Checks for updated package(s) in /var/db/pkg"); script_set_attribute( attribute:"synopsis", value: "The remote Gentoo host is missing one or more security-related patches." ); script_set_attribute( attribute:"description", value: "The remote host is affected by the vulnerability described in GLSA-200906-03 (phpMyAdmin: Multiple vulnerabilities) Multiple vulnerabilities have been reported in phpMyAdmin: Greg Ose discovered that the setup script does not sanitize input properly, leading to the injection of arbitrary PHP code into the configuration file (CVE-2009-1151). Manuel Lopez Gallego and Santiago Rodriguez Collazo reported that data from cookies used in the 'Export' page is not properly sanitized (CVE-2009-1150). Impact : A remote unauthorized attacker could exploit the first vulnerability to execute arbitrary code with the privileges of the user running phpMyAdmin and conduct Cross-Site Scripting attacks using the second vulnerability. Workaround : Removing the 'scripts/setup.php' file protects you from CVE-2009-1151." ); script_set_attribute( attribute:"see_also", value:"https://security.gentoo.org/glsa/200906-03" ); script_set_attribute( attribute:"solution", value: "All phpMyAdmin users should upgrade to the latest version: # emerge --sync # emerge --ask --oneshot --verbose '>=dev-db/phpmyadmin-2.11.9.5'" ); 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_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:"Phpmyadmin File Upload"); script_set_attribute(attribute:"exploit_framework_d2_elliot", value:"true"); script_set_attribute(attribute:"exploited_by_malware", value:"true"); script_set_attribute(attribute:"metasploit_name", value:'PhpMyAdmin Config File Code 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_cwe_id(79, 94); script_set_attribute(attribute:"plugin_type", value:"local"); script_set_attribute(attribute:"cpe", value:"p-cpe:/a:gentoo:linux:phpmyadmin"); script_set_attribute(attribute:"cpe", value:"cpe:/o:gentoo:linux"); script_set_attribute(attribute:"vuln_publication_date", value:"2009/03/26"); script_set_attribute(attribute:"patch_publication_date", value:"2009/06/29"); script_set_attribute(attribute:"plugin_publication_date", value:"2009/06/30"); script_set_attribute(attribute:"generated_plugin", value:"current"); script_end_attributes(); script_category(ACT_GATHER_INFO); script_copyright(english:"This script is Copyright (C) 2009-2019 and is owned by Tenable, Inc. or an Affiliate thereof."); script_family(english:"Gentoo Local Security Checks"); script_dependencies("ssh_get_info.nasl"); script_require_keys("Host/local_checks_enabled", "Host/Gentoo/release", "Host/Gentoo/qpkg-list"); exit(0); } include("audit.inc"); include("global_settings.inc"); include("qpkg.inc"); if (!get_kb_item("Host/local_checks_enabled")) audit(AUDIT_LOCAL_CHECKS_NOT_ENABLED); if (!get_kb_item("Host/Gentoo/release")) audit(AUDIT_OS_NOT, "Gentoo"); if (!get_kb_item("Host/Gentoo/qpkg-list")) audit(AUDIT_PACKAGE_LIST_MISSING); flag = 0; if (qpkg_check(package:"dev-db/phpmyadmin", unaffected:make_list("ge 2.11.9.5"), vulnerable:make_list("lt 2.11.9.5"))) flag++; if (flag) { if (report_verbosity > 0) security_hole(port:0, extra:qpkg_report_get()); else security_hole(0); exit(0); } else { tested = qpkg_tests_get(); if (tested) audit(AUDIT_PACKAGE_NOT_AFFECTED, tested); else audit(AUDIT_PACKAGE_NOT_INSTALLED, "phpMyAdmin"); }
NASL family FreeBSD Local Security Checks NASL id FREEBSD_PKG_06F9174F190F11DEB2F0001C2514716C.NASL description phpMyAdmin reports : Setup script used to generate configuration can be fooled using a crafted POST request to include arbitrary PHP code in generated configuration file. last seen 2020-06-01 modified 2020-06-02 plugin id 36012 published 2009-03-25 reporter This script is Copyright (C) 2009-2019 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/36012 title FreeBSD : phpmyadmin -- insufficient output sanitizing when generating configuration file (06f9174f-190f-11de-b2f0-001c2514716c) NASL family Debian Local Security Checks NASL id DEBIAN_DSA-1824.NASL description Several remote vulnerabilities have been discovered in phpMyAdmin, a tool to administer MySQL over the web. The Common Vulnerabilities and Exposures project identifies the following problems : - CVE-2009-1150 Cross site scripting vulnerability in the export page allow for an attacker that can place crafted cookies with the user to inject arbitrary web script or HTML. - CVE-2009-1151 Static code injection allows for a remote attacker to inject arbitrary code into phpMyAdmin via the setup.php script. This script is in Debian under normal circumstances protected via Apache authentication. However, because of a recent worm based on this exploit, we are patching it regardless, to also protect installations that somehow still expose the setup.php script. last seen 2020-06-01 modified 2020-06-02 plugin id 39569 published 2009-06-30 reporter This script is Copyright (C) 2009-2019 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/39569 title Debian DSA-1824-1 : phpmyadmin - several vulnerabilities NASL family SuSE Local Security Checks NASL id SUSE_PHPMYADMIN-6133.NASL description This update of phpMyAdmin fixes multiple vulnerabilities : - CVE-2009-1148: directory traversal - CVE-2009-1149: CRLF injection - CVE-2009-1150: cross-site scripting - CVE-2009-1151: static code injection last seen 2020-06-01 modified 2020-06-02 plugin id 36081 published 2009-04-03 reporter This script is Copyright (C) 2009-2019 Tenable Network Security, Inc. source https://www.tenable.com/plugins/nessus/36081 title openSUSE 10 Security Update : phpMyAdmin (phpMyAdmin-6133)
Packetstorm
data source https://packetstormsecurity.com/files/download/84526/phpmyadmin_config.rb.txt id PACKETSTORM:84526 last seen 2016-12-05 published 2009-12-31 reporter PAgVac source https://packetstormsecurity.com/files/84526/PhpMyAdmin-Config-File-Code-Injection.html title PhpMyAdmin Config File Code Injection data source https://packetstormsecurity.com/files/download/78220/phpmyadminrcesh.txt id PACKETSTORM:78220 last seen 2016-12-05 published 2009-06-10 reporter PAgVac source https://packetstormsecurity.com/files/78220/phpMyAdmin-scripts-setup.php-Code-Injection.html title phpMyAdmin /scripts/setup.php Code Injection
Seebug
bulletinFamily exploit description 漏洞位置在scripts/setup.php 1315行开始: case 'save': $config = @fopen('./config/config.inc.php', 'w'); //以写的方式打开 if ($config === FALSE) { message('error', 'Could not open config file for writing! Bad permissions?'); break; } $s = get_cfg_string($configuration); //$configuration = unserialize($_POST['configuration']); $r = fwrite($config, $s); 当$_POST['action']=='save'时,get_cfg_string($configuration)的返回结果将被写入/config/config.inc.php文件中。 其中, function get_cfg_string($cfg) { ...... foreach ($c as $key => $val) { $ret .= get_cfg_val("\$cfg['$key']", $val); //这里进入get_cfg_val函数 } $ret .= '?>' . $crlf; return $ret; } function get_cfg_val($name, $val) { global $crlf; $ret = ''; if (is_array($val)) { ...... } else { $ret .= $name . ' = ' . PMA_var_export($val) . ';' . $crlf; //这里 } return $ret; } 可见,get_cfg_val函数并没有对$name进行过滤。 因此,当$_POST['configuration']反序列化后包含array数组时,函数并不会对数组的键值$key进行过滤。 通过修改数组的键值$key,并最终写入到/config/config.inc.php文件中,可以造成了任意代码执行。 id SSV:71406 last seen 2017-11-19 modified 2014-07-01 published 2014-07-01 reporter Root source https://www.seebug.org/vuldb/ssvid-71406 title PhpMyAdmin Config File Code Injection bulletinFamily exploit description BUGTRAQ ID: 34236 CVE(CAN) ID: CVE-2009-1151 phpMyAdmin是用PHP编写的工具,用于通过WEB管理MySQL。 phpMyAdmin的Setup脚本用于生成配置。如果远程攻击者向该脚本提交了特制的POST请求的话,就可能在生成的config.inc.php 配置文件中包含任意PHP代码。由于配置文件被保存到了服务器上,未经认证的远程攻击者可以利用这个漏洞执行任意PHP代码。 phpMyAdmin phpMyAdmin 3.x phpMyAdmin phpMyAdmin 2.11.x 厂商补丁: phpMyAdmin ---------- 目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载: <a href="http://phpmyadmin.svn.sourceforge.net/viewvc/phpmyadmin?view=rev&revision=12301" target="_blank" rel=external nofollow>http://phpmyadmin.svn.sourceforge.net/viewvc/phpmyadmin?view=rev&revision=12301</a> id SSV:11665 last seen 2017-11-19 modified 2009-06-19 published 2009-06-19 reporter Root source https://www.seebug.org/vuldb/ssvid-11665 title phpMyAdmin setup.php脚本PHP代码注入漏洞 bulletinFamily exploit description No description provided by source. id SSV:11571 last seen 2017-11-19 modified 2009-06-11 published 2009-06-11 reporter Root source https://www.seebug.org/vuldb/ssvid-11571 title phpMyAdmin (/scripts/setup.php) PHP Code Injection Exploit
References
- http://labs.neohapsis.com/2009/04/06/about-cve-2009-1151/
- http://labs.neohapsis.com/2009/04/06/about-cve-2009-1151/
- http://lists.opensuse.org/opensuse-security-announce/2009-04/msg00003.html
- http://lists.opensuse.org/opensuse-security-announce/2009-04/msg00003.html
- http://phpmyadmin.svn.sourceforge.net/viewvc/phpmyadmin/branches/MAINT_2_11_9/phpMyAdmin/scripts/setup.php?r1=11514&r2=12301&pathrev=12301
- http://phpmyadmin.svn.sourceforge.net/viewvc/phpmyadmin/branches/MAINT_2_11_9/phpMyAdmin/scripts/setup.php?r1=11514&r2=12301&pathrev=12301
- http://secunia.com/advisories/34430
- http://secunia.com/advisories/34430
- http://secunia.com/advisories/34642
- http://secunia.com/advisories/34642
- http://secunia.com/advisories/35585
- http://secunia.com/advisories/35585
- http://secunia.com/advisories/35635
- http://secunia.com/advisories/35635
- http://security.gentoo.org/glsa/glsa-200906-03.xml
- http://security.gentoo.org/glsa/glsa-200906-03.xml
- http://www.debian.org/security/2009/dsa-1824
- http://www.debian.org/security/2009/dsa-1824
- http://www.gnucitizen.org/blog/cve-2009-1151-phpmyadmin-remote-code-execution-proof-of-concept/
- http://www.gnucitizen.org/blog/cve-2009-1151-phpmyadmin-remote-code-execution-proof-of-concept/
- http://www.mandriva.com/security/advisories?name=MDVSA-2009:115
- http://www.mandriva.com/security/advisories?name=MDVSA-2009:115
- http://www.phpmyadmin.net/home_page/security/PMASA-2009-3.php
- http://www.phpmyadmin.net/home_page/security/PMASA-2009-3.php
- http://www.securityfocus.com/archive/1/504191/100/0/threaded
- http://www.securityfocus.com/archive/1/504191/100/0/threaded
- http://www.securityfocus.com/bid/34236
- http://www.securityfocus.com/bid/34236
- https://www.exploit-db.com/exploits/8921
- https://www.exploit-db.com/exploits/8921