View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0005956 | mantisbt | security | public | 2005-07-16 19:34 | 2006-10-09 11:55 |
| Reporter | joxeanpiti | Assigned To | vboctor | ||
| Priority | normal | Severity | major | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | 0.19.2 | ||||
| Fixed in Version | 1.0.0rc1 | ||||
| Summary | 0005956: Database system scanner via variable poisoning | ||||
| Description | If the 'register_globals' directive is enabled the script located at <mantis_dir>/core/database_api.php is vulnerable to variable poisoning attacks. By exploiting the vulnerability an attacker can connect to databases that are in the web server LAN. NOTE: This only works if the 'register_globals' directive is On. | ||||
| Additional Information | To reproduce the behavior simply navigate to any of these urls: http://bugs.mantisbt.org/core/database_api.php?g_db_type=mysql://invaliduser@localhost:3336 http://bugs.mantisbt.org/core/database_api.php?g_db_type=mysql://root@localhost:3336 http://bugs.mantisbt.org/core/database_api.php?g_db_type=informix://localhost:8080 Due to this vulnerability you can write a database scanner or a network scanner by simply changing the hostname. Examples: 2.- http://bugs.mantisbt.org/core/database_api.php?g_db_type=mysql://root@localhost 3.- | ||||
| Tags | No tags attached. | ||||
| Attached Files | 0005956.patch (502 bytes)
--- database_api.orig 2005-07-18 16:43:36.000000000 +0200
+++ database_api.php 2005-07-18 16:49:43.000000000 +0200
@@ -9,6 +9,13 @@
# $Id: database_api.php,v 1.42 2005/02/26 15:16:46 thraxisp Exp $
# --------------------------------------------------------
+ #
+ # Patch for #0005956: Database system scanner via variable poisoning
+ #
+
+ if (isset($_REQUEST["g_db_type"]))
+ die("");
+
### Database ###
# This is the general interface for all database calls.
modified.patch (531 bytes)
--- database_api.orig 2005-07-18 16:43:36.000000000 +0200
+++ database_api.php 2005-07-18 16:49:43.000000000 +0200
@@ -9,6 +9,13 @@
# $Id: database_api.php,v 1.42 2005/02/26 15:16:46 thraxisp Exp $
# --------------------------------------------------------
+ #
+ # Patch for #0005956: Database system scanner via variable poisoning
+ #
+
+ if ((isset($_GET["g_db_type"])) || (isset($_GET["g_db_type"])))
+ die("");
+
### Database ###
# This is the general interface for all database calls.
| ||||
|
This may also be used to conduct Cross Site Scripting attacks. Example: http://bugs.mantisbt.org/core/database_api.php?g_db_type=<h1>hi</h1> |
|
|
Hi joxeanpiti, I've committed a fix to our CVS that fixes this issue (amongst other things) RCS file: /cvsroot/mantisbt/mantisbt/core/database_api.php,v When Sourceforge's public cvs catches up with real life, you'll be able to see the patch at http://cvs.sourceforge.net/viewcvs.py/mantisbt/mantisbt/core/database_api.php under version 1.43. At the moment, this patch will appear in 1.0.0RC1 (which we plan to release in the next few days). Instead of using $g_db_type directly, we call config_get('db_type'). This function is undefined if you call database_api directly, so I believe should resolve this issue. The current behaviour of our new install.php is to treat register_globals being enabled as a fatal error (albeit this version is not yet released), with check.php which checks the setup of a mantis installation e.g. mail, database etc also treats register_globals as a fatal error. I've included Victor in on this issue, and will leave it up to him whether this warrants releasing a patched version of 0.19.2. When sf.net's viewcvs starts showing version 1.43, please take a look and see if you believe that the new version resolves your issue. Thanks |
|
Of course. And one question: all prior versions are vulnerables as well, right? |
|
|
Verified. Version 1.43 of <mantis_dir>/core/database_api.php fixes the problem. |
|
|
It would be useful if you can include the fix for the security problem as a note in this issue. We can then decide to port it back to 0.19.2 or just make a post to notify users about it and how it can be fixed. Ideally, the fix should be as simple as possible to explain and apply. |
|
Ok. I will publish it today (if I can). |
|
|
I have been attached a patch that works for (any?) prior versions as well as the current of Mantis BT. |
|
|
hi joxeanpiti, Unfortunately, that won't quite work -> It'll work with Mantis + PHP 4.1 and above It won't work with Mantis + PHP 4.0.6, as $_REQUEST only came into existance in PHP 4.1 and above. I'd anticipate that in 0.19.2, the simplest 'patch/hack' would be to replace: $g_db = $db = ADONewConnection($g_db_type); From database api, with: $g_db = $db = ADONewConnection( config_get( $g_db_type ) ); Although, i've not verified this in anyway. As security vulnerabilities go, unless i'm missing something else, this seems like a 'minor-medium vulnerability', which could be exploited more through social engineering. Given the following: a) you know of a public instance of mantisbt ( < version 1.0.0RC1 i.e. all current releases) Then you can: a) Provide a link, which you'd then need to persuade a user to manually visit, and then use in a cross site scripting attack. This code flaw exists in the following releases: 1.0.0a3 I introduced this issue in http://cvs.sourceforge.net/viewcvs.py/mantisbt/mantisbt/core/database_api.php?r1=1.20&r2=1.21 which was March 2004. wonders if anyone agrees or disagrees with that analysis Paul |
|
Yes. This is clearly a "disclosure", not a directly exploitable flaw. To exploit it you need to use any kind of social engineering. I have been attached a POC about the issue and a modified patch. |
|
|
Fixed in CVS. |
|