Forum Moderators: open
Thanks,
Umar Rahman
[edited by: jatar_k at 12:03 pm (utc) on May 23, 2008]
[edit reason] no urls thanks [/edit]
I have already removed all occurances of it from my DB by doing a find and replace (using Access to connect to the SQL DB) and have checked the user securities for the DB removing any data writing capabilities from those that don't require it (or can do without it for now).
I have also noticed that if you put the offending script in google there are several sites that come up which are obviously not aware they are affected.
If I work out how it was introduced I'll post it here.
[edited by: jatar_k at 1:13 pm (utc) on May 26, 2008]
Yep we've got this too...
<sript src=http://www.example.com/b.js></sript><sript src=http://www.example.com/b.js></sript>
(removed the sCript)
Zaphod: any chance of putting your clean up code here?
All: can someone expand on how to prevent this from happening please?
Thanks
[edited by: jatar_k at 3:52 am (utc) on May 28, 2008]
[edited by: txbakers at 8:08 pm (utc) on May 28, 2008]
[edit reason] url [/edit]
Create a new user in the DB with read-only access, then update the connection strings in the asp pages to use that account.
The above were instructions that we sent to someone who experienced the same attack. I believe you'll also need to restore the db to a date prior to the hack.
Its a rather nasty one too. I believe it inserts the actual scripts into the sql records. It happens due to the way the sql statements are set up on the actual asp page. Apparently there is an exploit there and it all goes back to how the page was programmed. I'm not a programmer so I know just enough to get me into trouble. ;)
I'd like to send out a plea to all Webmasters to double check your website installations. This is a rather nasty hack and the payload is a bit unfriendly. A landing page with multiple <iframes> each one doing something different to the user. Scary stuff.
For those of you on Windows, I'll bet some of you have a big gaping hole in some of your asp pages and don't even know it. Check your sql records for the .js scripts. It is truly viral.
2008-04-28 - No New IIS Or Microsoft SQL Server Vulnerabilities, Despite Claims
[webmasterworld.com...]
2008-04-28 - Half a million sites hit by huge web hack
[techworld.com...]
2008-05-15 - Phishing botnet turns to SQL-injection attack
[techworld.com...]
It's so bad, in fact, that while security companies urged website administrators to check their server logs for evidence of a compromise, and told corporate security staffs to block several malware-hosting sites at their companies' perimeters, they didn't have much useful advice for end-users.
This was interesting...
After the Asprox botnet seeds its bots with the msscntr32.exe file, the attack tool launches and uses Google's search engine to find potentially-vulnerable pages. It then hits those pages with a SQL-injection attack and, if successful, plants a malicious IFRAME on the site.
Emphasis mine. Search Google for Goolag.
i think robots are searching for asp pages that use querystrings such as:
?prodid= or ?productid= or ?id= [and probably more]
it is then requesting those pages using a querystring such as:
?productID=10;DECLARE%20@S%20NVARCHAR(4000);SET%20@S=CAST(0x440045004 [+ hundreds more characters]
to combat this you need to clean your data before you query the database.
eg.
if you are doing something like
select * from table where productid=" & request["productid"]
then you are in BIG trouble
you must first test request["productid"] to see that it is a value you expect it to be, perhaps an integer only, or a string but it won't be longer than 20 characters for instance.
you should also use stored procedures as well.
note that cleaning your db table fields is only temporary, unless you clean up the way you query the database it will just be reinfected.
also i'm not sure if this attack is targeted at forms as well, but it is certainly targetted at parameters passed in querystrings.
as an aside, most of these attacks seem to be coming from china, but not all of them.
this js then builds the iframe and so on.
the damage to you is just the loss of data in your db when the injection attack happens - it writes the code for the js include into database fields it thinks are appropriate.
you then serve the pages - the person that visits your page with js turned on is the one who really sufers, their computer is potentially comprimised
You then serve the pages - the person that visits your page with js turned on is the one who really sufers, their computer is potentially comprimised.
And, if you are one of the unfortunate ones where the hack has been present for more than one or two indexings, you may be the recipient of this...
[google.com...]
[edited by: pageoneresults at 11:31 am (utc) on May 27, 2008]
Can we be absolutely clear about what systems are infected here?
According to my Lead Programmer, no. I've got him reviewing this topic as we have an interest here. He's been dealing with sql injection attacks since the late 90s.
Here is some of the commentary I am currently having with him via IM...
the last comment on that is good. "note that cleaning your db table fields is only temporary, unless you clean up the way you query the database it will just be reinfected."
unfortunatley for mysql and most beginner sites are still using sql statement inside the asp/php scripts especially when mysql is free and designed for begining sites, and they don't offer stored procedures (or the advanced paid version only offers limited stored procedure options.
also, i'll need to check the latest mysql. they might have added a few more features. but the problem are most users prefer "Select * from tblUsers" than to create a stored procedure, set the parameters and call it. to them its additional steps.
btw, this issue can happen on any system (asp, jsp, asp.net, php) and any database (mysql, access, Mssql, oracle). it's always about best coding practices and knowing how to set the security. that's why dba gets paid $$$$$.
if walmart's database is down and the latest one they can restore is 1 hr ago. they're in huge trouble. that's several terabytes of transactions lost.
2008-05-05 - Under Attack! Hacker attacked DB with link to virus
[webmasterworld.com...]
2007-11-19 - Avoiding SQL injection attacks without the need to replace words
[webmasterworld.com...]
From the above topic, Ocean10000 posted these links...
How To: Protect From SQL Injection in ASP.NET
[msdn.microsoft.com...]
How To: Protect From Injection Attacks in ASP.NET
[msdn.microsoft.com...]
Anti-Cross Site Scripting Library
[msdn.microsoft.com...]
And then a slightly older topic. Apparently this is not something new...
2006-02-19 - SQL Injection Vulnerability - What measures Should be Taken Against
[webmasterworld.com...]
I know this bit is the temporary solution but I've fixed the ASP code now and restricted the SQL user's access.
We've had quite a few(!) new records since the last "good" backup so it will be easier to find/replace all the "script" code that's been appended.
Thank you.
Can we be absolutely clear about what systems are infected here?Operating system, scripting / CGI language, database type?
SQL injection can happen with any OS, any scripting language, and any SQL database as soon as there is an SQL database around.
It is very common in PHP, as PHP programmers are used to do this like:
(BAD BAD BAD DON'T DO IT)
mysql_query("SELECT * FROM table WHERE id=" . $_GET[id]);
which means that if the id passed is not checked, it may contain additional SQL, and the attacker can do anything they want on your database.
In the majority of other languages (and now in PHP as well I believe, but it requires a switch to more recent APIs), you can use placeholders. E.g. in perl:
$dbh->selectrow_array("SELECT * FROM table WHERE id=?",undef,$vars{id})
This means the driver or abstraction layer will make sure that the ? will be replaced by the value passed, but correctly quoted so it can only be considered a value (usually an integer or a string), and can't be interpreted as SQL code.
However, even in languages or with APIs that do provide placeholder syntax, many developpers still insert unchecked input directly into SQL queries, which is a very bad idea.
So, the advice is:
- if at all possible, switch to using a syntax with placeholders and separate values. Make sure you never insert a variable received from a web client directly into an SQL query, always use a placeholder
- if not, always check your input (e.g. that integers are actually integers), and for text always use the appropriate "quoting"/"escaping" function (that will make sure that the value passed is considered as a literal and nothing else) before inserting it into a query
Of course, the worst case scenario is with the tons of software "out there" containing such code that has been copied thousands if not millions of times by webmasters all over the world who have no idea of what this all means :-(
Jacques.
We've found installing Mod_Security for Apache and keeping your conf file uptodate eliminates the vast majority of automated injection,xmlrpc,tmp,shell,foreign css and other attacks you will face .
It's quite easy to install and keeps a decent log of when, where and what was blocked for debuging .
Checkin it out : [modsecurity.org...]
>> the problem are most users prefer "Select * from tblUsers" than to create a stored procedure, set the parameters and call it
well, that isn't very concise. Properly processing all data from outside sources is the issue, whether you use a standard select or a stored procedure has little to do with it.
sorry pageone, that's been sticking in my craw since this morning. :)
>> if at all possible, switch to using a syntax with placeholders and separate values. Make sure you never insert a variable received from a web client directly into an SQL query
again, you don't need to switch to any particular system, the second part is the important part but I would take it a step farther
Never trust data from any outside source