Smack Digital Inc.

How To Secure X-Cart

Posted by and last updated Jan 22, 2014 04:33 PM

Take control of your X-Cart security by following the necessary steps to help secure your X-Cart from hacks and exploits.

X-Cart makes it easy for nearly anyone with the desire to establish an e-commerce store to do so, however not everyone has the background knowledge to know to address security issues. Many store owners begin designing, adding products, and focusing on sales and SEO without ensuring that their X-Cart e-commerce store is developed in a secure environment with a focus on security. Once established often X-Cart store owners are not aware of what is required to maintain their X-Cart in a manner that keeps it secure over time.

The importance of X-Cart security

Website security should always be a priority, but is absolutely crucial when dealing with e-commerce stores that transact and store sensitive customer data such as email addresses, phone numbers, addresses, and credit card information. Reading through the X-Cart forums you will find many X-Cart store owners who have had the misfortune of having their X-Cart hacked/exploited. Having worked with X-Cart since 2002, we've had many of those store owners come to us asking what can be done to fix their store. We've heard repeatedly the common response that nobody had ever talked to them about security and they were unaware of anything that needed to be done. Believe me when I say that if you are not aware of what is required to secure and maintain your X-Cart, it is by sheer luck that your X-Cart has not been hacked or exploited and it is only a matter of time before you become a victim. That said, by reading this tutorial you are well on your way to understanding and performing X-Cart security to keep you and your customers safe.

Hosting X-Cart in a secure environment

The environment on which your X-Cart is hosted is the base for all security, and if your host and/or server is not secure, all the security settings on your X-Cart are not going to keep you from being exploited. There are generally two types of hosting: a shared server where you purchase a plan with a host and they provide you space for your site to reside on a server with many other clients, or a dedicated server, which is a computer where you can host your site(s) exclusively (a VPS is essentially a combination allowing dedicated server privileges in an environment shared with less users than with shared hosting). Cloud hosting is a form of shared server.

Secured Shared Hosting

The main benefits of shared hosting are the reduced cost available by sharing the server with other users, and having the server company manage the server security. These same benefits can also pose a security threat however, as the sites of other clients can jeopardize your security if their sites are breached, and if you rely on a server company to secure a server and they fail to do so correctly, you can find yourself in serious trouble. To combat these potential problems, it is imperative that you host with a trusted hosting provider who makes server security a priority. We highly recommend Hands On Web Hosting or EWD Hosting.

Dedicated Server


I unfortunately often see X-Cart store owners establish or move to an unmanaged dedicated server without knowing the onus of security that falls on them in doing so. When working with an unmanaged server, you are responsible for ALL server security. This includes the configuration of all your server settings, as well as keeping your kernel, os, php/mysql, control panel, etc. up-to-date as new branches and patches are released. This is a daunting task for anyone not very experienced with server security, and is not recommended for the average user.


Surprisingly, having a managed server does not necessarily mean your server is secure. When purchasing a managed plan, it is important to know what the server provider will and won't do as part of your managed plan; it is not uncommon for someone to established a managed server and setup their site(s) thinking the host will take care of security, only to find their server exploited to which the server company responds saying they only perform security tasks upon request. If you rely on your host for a fully managed security package it is important that you work with a trusted hosting provider who takes security seriously, and ensure that all aspects of security are accounted for.

How to secure your X-Cart

After securing the hosting environment, it is necessary to address security with X-Cart itself. Taking the following steps will make great strides in securing your X-Cart:

  1. Ensure you have a secure https connection for your store using a valid SSL certificate.

  2. Do not use the "master" X-Cart admin account. To change this, login using your "master" X-Cart admin account, create a new administrator with a username that is less generic. Log in as that new user and delete the "master" user account.

  3. Immediately password protect your admin and provider directories. You can usually password protect these directories using a control panel such as cPanel, or you can use .htaccess and .htpasswd files (run a quick Google search if you are unsure how).

  4. Be aware of your site's file permissions, as having loose file permissions in conjunction with an exploit, can allow someone to write and execute files on your website - this is a very common exploit against X-Cart so take this seriously. In general your file chmod permissions should appear as follows:

    Files Ideal Otherwise
    *.php 644 644
    *.tpl 644 644
    *.pl 755 755
    *.sh 755 755
    /catalog/ 755 777
    /files/ 755 777
    /images/ 755 777
    /var/ 755 777
    /var/* folders 755 777
    /var/* files 644 666

  5. Turn off the option of sending credit card information in e-mails in the General Settings -> Email section of your X-Cart admin section.

  6. Unless you are using the subscriptions module, do not store credit card information in your database. To disable, or to ensure that this setting is disabled, open your config.php file and ensure the $store_cc variable is set to false:

    $store_cc = false;

  7. It is always a good idea to log into your X-Cart admin section using https so that the data you transact during the X-Cart session is encrypted. The following code will force your X-Cart admins/providers to login using https:// by redirecting them when http:// is used.

    Add this code to the .htaccess of your admin section (adjust your url):
    # Force https on the admin section
    RewriteEngine On
    RewriteCond %{SERVER_PORT} !443
    RewriteRule ^(.*)$ https://www.example.com/admin/$1 [R=301,L]

    Add this code to the .htaccess of your provider section (adjust your url):
    # Force https on the provider section
    RewriteEngine On
    RewriteCond %{SERVER_PORT} !443
    RewriteRule ^(.*)$ https://www.example.com/provider/$1 [R=301,L]

  8. The following .htaccess code, which can be placed in an .htaccess file in your store's root directory (same directory as home.php and cart.php), will prevent access to sensitive areas of the X-Cart file structure. If you are on a server that does not support .htaccess files, you will want to find alternate ways to block access to these files.

    (NOTE: Change http://www.example.com/ to the url to your error_message.php file.)

    Options +SymlinksIfOwnerMatch -Indexes
    RewriteEngine on

    RedirectMatch permanent ^.*/.pgp/.*$ http://www.example.com/error_message.php
    RedirectMatch permanent ^.*/sql/.*$ http://www.example.com/error_message.php
    RedirectMatch permanent ^.*/schemes/.*$ http://www.example.com/error_message.php
    RedirectMatch permanent ^.*/upgrade/.*$ http://www.example.com/error_message.php

    # Block access to sensitive files types
    RedirectMatch permanent ^.*.(ini|tpl|sql|log|conf|bak)$ http://www.example.com/error_message.php

    # Block access to sensitive files
    RedirectMatch permanent ^.*/COPYRIGHT http://www.example.com/error_message.php
    RedirectMatch permanent ^.*/INSTALL.*$ http://www.example.com/error_message.php
    RedirectMatch permanent ^.*/NEW.*$ http://www.example.com/error_message.php
    RedirectMatch permanent ^.*/README http://www.example.com/error_message.php
    RedirectMatch permanent ^.*/UPGRADE.*$ http://www.example.com/error_message.php
    RedirectMatch permanent ^.*/VERSION http://www.example.com/error_message.php
    RedirectMatch permanent ^.*/include/version.php http://www.example.com/error_message.php
    RedirectMatch permanent ^.*/config.php http://www.example.com/error_message.php
    RedirectMatch permanent ^.*/top.inc.php http://www.example.com/error_message.php

    # Uncomment this line if installing
    RedirectMatch permanent ^.*/install.php$ http://www.example.com/error_message.php

Hire experienced and reputable developers

Developers can introduce exploits into your site either accidentally or on purpose. When coding on one client site, we once found a backdoor left that would allow the developer to delete the entire client site from a specially formulated url if they choose to do so. I'll say it again - hire a reputable developer! Also hire an experienced developer who takes security seriously. When interviewing a developer for your site, ask them what steps they take to ensure their code is secure and ask if their code has ever been exploited. If so, ask them how and what they now do to ensure it doesn't happen again. If a developer seems lackadaisical about answering security questions, think twice about hiring them.

Maintenance of X-Cart security

A big mistake I see with users of software is thinking they can setup the software and run the software for an indefinite period of time. It is imperative with X-Cart, and all software you run for that matter, that you apply security patches and upgrade as new releases are available. While the patches and upgrades do require time and/or money to apply, neglecting to do so can be potentially fatal to your business and they need to be made a priority.

X-Cart provides security and release bulletins that you can sign up for in your X-Cart client account. Be sure to sign-up for these bulletins and stay on top of your security.

About the Author

Jonathan Peters Jonathan's founder of Smack Digital, a digital strategy agency that creates and executes online business success for executives who are highly motivated to quickly increase their market share. With more than two decades of experience on the web for clients ranging from non-profits to billion dollar enterprises, Jonathan's an expert in web development, eCommerce, software programming, search engine optimization and social media marketing.

Browse By Category

RSS Feeds

Don't miss out! Subscribe to our RSS Feeds to receive instant notification when new entries are added.

RSS Feed for All Categories
RSS Feed for X-Cart How-Tos
We choose our clients selectively.
Let's talk success. Apply to work with us.
Apply toWork With Us
Apply toWork With Us