SQL-Injections in Mapbender
During a penetration test RedTeam Pentesting discovered multiple SQL-Injections in Mapbender. A remote attacker is able to execute arbitrary SQL commands and therefore can get e.g. valid usernames and password hashes of the Mapbender users.
Affected Versions: 2.4.4 (verified), probably older versions, too
Fixed Versions: 2.4.5 rc1
Vulnerability Type: SQL-Injection
Vendor-Status: informed, fixed version released
(from the vendor's homepage)
Due to the lack of input validation, an attacker is able to inject SQL-commands in many PHP scripts of Mapbender. This vulnerability can be exploited regardless of PHP magic quotes. For demonstration purposes, the injection into the "gaz" variable of the file
http/php/mod_gazetteer_edit.php is shown.
The two relevant lines are:
$sql = "SELECT * FROM gazetteer WHERE gazetteer_id = ".$_REQUEST["gaz"]; $res = db_query($sql);
The user input $_REQUEST["gaz"] goes unfiltered, unquoted and unescaped into an SQL statement. As no prepared statements are used here, an attacker can execute arbitrary SQL commands.
There is no need to use quotes in the SQL statement for an attacker, so PHP magic quotes do not help.
Proof of Concept
The following request retrieves the first username and password hash from the Mapbender database.
http://www.example.com/php/mod_gazetteer_edit.php?gaz= 1 LIMIT 0 UNION
(SELECT char(65), char(65), char(65), char(65), char(65), char(65), mb_user_name, char(65), mb_user_password, char(65) from mb_user LIMIT 0,1)
The vulnerability is fixed in release 2.4.5 rc1.
As an attacker is able to e.g. get the password hashes of the administrators and other users, the risk is estimated as high.
2007-12-14 Problem identified during a penetration test
2008-01-09 Customer approves contacting of Mapbender developers
2008-01-17 CVE number assigned
2008-03-10 Vendor releases fixed version
2008-03-11 Advisory released
2009-05-08 Updated Advisory URL
RedTeam Pentesting GmbH
RedTeam Pentesting offers individual penetration tests, short pentests, performed by a team of specialised IT-security experts. Hereby, security weaknesses in company networks or products are uncovered and can be fixed immediately.
As there are only few experts in this field, RedTeam Pentesting wants to share its knowledge and enhance the public knowledge with research in security-related areas. The results are made available as public security advisories.
More information about RedTeam Pentesting can be found at http://www.redteam-pentesting.de.