Home » Item #997
I have heard about a damaging SQL injection attack that has compromised many database driven web sites. My logs show what appear to be attempts by this to break into my site. Is CactuShop vulnerable? What can I do to protect myself?
The specific attack we've seen is detailed here:
TechNewsWorld: Mass SQL Attack a Wake-Up Call for Developers
At present it only affects MS SQL sites, but could in future be modified to attack MySQL. Attacking Access would be harder.
The purpose of the attack seems to be to inject javascript code into every text, ntext, varchar and nvarchar field, in the hope that the site serves this javascript to users along with its normal page content. The javascript code attempts to download a trojan to the vistor's computer or exploit unpatched browsers.
Is CactuShop vulnerable?
Security vendors routinely review code for web applications to find SQL injection and other vulnerabilities. We are not aware of any SQL injection vulnerabilities in any CactuShop above v5.121 (June 2004), including all v6 and v6.1 versions. Versions prior to this could be vulnerable.
We did recently have an incident reported where the database of a v6.1 CactuShop was affected, but examination of the logs revealed that the flaw was in an unrelated (non-CactuShop) script that connected to the same database. The malicious code did not enter through CactuShop.
The attack itself was not particularly sophisticated in terms of the entry method, so all CactuShops above 5.121 should be safe. Versions for some time before that release may be vulnerable in theory, although in practice the vulnerabilities identified were more obscure and would be harder for an automated attack like this to find. The biggest risk is to very old CactuShops such as v4 or earlier (2003), or to CactuShops that have been modified or had new scripts added by third parties that may not employ measures to defend against SQL injection.
Safety precautions
We would prefer not to be complacent. Expert members on the IIS.net web site have come up with some measures for MS SQL databases that can act as a good safeguard against this particular attack.
We would recommend these even for the latest CactuShop installs, as an extra safeguard which has no negative impact on the store performance.
The following query, run as a user with admin privileges for your site database, will remove select permissions on MS SQL 2005+ system tables that the attack needs access to, thereby preventing the database from being hacked by this particular attack even if an SQL vulnerability were found:
use [databasename]
GO
deny select on sysobjects to [useraccount]
GO
deny select on syscomments to [useraccount]
GO
deny select on syscolumns to [useraccount]
GO
deny select on systypes to [useraccount]
GO