Half a Million Microsoft-Powered Sites Hit With SQL Injection
Titus Germanicus writes to tell us that a recent attack has compromised somewhere in the neighborhood of 500,000 pages with a SQL injection attack. The vulnerability seems to be limited to Microsoft's IIS webserver and is easily defeated by the end user with Firefox and "NoScript." "The automated attack takes advantage to the fact that Microsoft's IIS servers allow generic commands that don't require specific table-level arguments. However, the vulnerability is the result of poor data handling by the sites' creators, rather than a specific Microsoft flaw. In other words, there's no patch that's going to fix the issue, the problem is with the developers who failed follow well-established security practices for handling database input. The attack itself injects some malicious JavaScript code into every text field in your database, the Javascript then loads an external script that can compromise a user's PC." Ignoring corporate spin-doctoring, there seems to be plenty of blame to go around.
As a coder, I don't agree with that. You make a tool/language/framework for developers, you better make it idiot proof. Example: C is far from idiot proof (seg fault!) but it's fast. Stupid fast. Unfortunately for C, there are more stupid coders out there like me than genuis coders out there like
Wow, for flaim retardant reasons, take the above paragraph as my meager opinion.
My work here is dung.
500 Thousand MS Web Servers Hacked
Posted by kdawson on Friday April 25, @11:48AM
from the scream-and-shout dept.
http://it.slashdot.org/it/08/04/25/1358234.shtml
[Fuck Beta]
o0t!
Wasn't this exact item posted on Friday? http://it.slashdot.org/article.pl?sid=08/04/25/1358234
Thought you could sneak it by at 5 o'clock, but I caught ya...
http://it.slashdot.org/article.pl?no_d2=1&sid=08/04/25/1358234
No comprende? Let me type that a little slower for you...
Much?
http://it.slashdot.org/it/08/04/25/1358234.shtml
Isn't this a dupe? I remember the same story from a couple of weeks back...?
I've seen dupes and all on Slashdot, but this an extreme case. I think this was posted last week, and it wasn't even a good article to begin with. Grats?
[quote]
Titus Germanicus writes to tell us that a recent attack has compromised somewhere in the neighborhood of 500,000 pages with a SQL injection attack. The vulnerability seems to be limited to Microsoft's IIS webserver and is easily defeated by the end user with Firefox and "NoScript".
[/quote]
Now, that makes sense. If you have an IIS installation, simply install Firefox and NoScript and you fix all your SQL injections!
"is easily defeated by the end user with Firefox and "NoScript"." Well, that protects the end user from the compromised server, but not the compromised server from the compromising script. This is not really a vulnerability in IIS, but it is a design decision that means the compromising script can exploit vulnerabilities in badly-written webapps more easily, so it's slightly Microsoft's fault. It's mostly the fault of all the developers who don't know or don't care about SQL injection, though. The same sort of attack could work against any make of server (because it exploits vulnerabilities in the code running on that server), but would be less easy to automate. And of course, the final end-user-compromising vulnerability has to target the end user, who ought to be protected against malicious websites, but many of who won't be...
(1)DOCOMEFROM!2~.2'~#1WHILE:1<-"'?.1$.2'~'"':1/.1$.2'~#0"$#65535'"$"'"'&.1$.2'~'#0$#65535'"$#0'~#32767$#1"
You know, as an incompetent Java developer, I will take the time to explain why none of my web applications suffered from this.
.NET.
...
I use Hibernate. I use it with Java, although I know it's now available for
A feature of Hibernate (aside from some efficient connection pooling and resource management like caching) is that you have to actually call a delete method to delete a row. Something like HibernateSession.delete(myObject); would have to be done. And while this might sound annoying or ruin some tools that are used to generate SQL statements, it protects me time and time again. Now, you can use HQL which is a bastardized version of SQL to generate similar things but, again, I think that you can't drop/delete in it (could be wrong, rarely use it).
Try passing part of an SQL string into an object property and then merge/save it into the HibernateSession. Doesn't do the SQL injection stuff the bad guys want it to. Of course, I still use regular expression common utilities to validate the input, but assuming you didn't do that
So why don't other people use Hibernate? Am I missing something about it that's bad?
My work here is dung.
What I don't get, though, is not only does this dupe the earlier story, it dupes ALL OF THE ERRORS as well. Sheesh!
It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
...with a user wanting to inject images from other websites into my pages.
I solved it quite nicely by translating any opening bracket to "ampersand-gt-;" (you know what I mean) and any urls were totally ignored after that.
Once I was a four stone apology. Now I am two separate gorillas.
A buffer overflow in the dupcheck module leads to privilege elevation.
You can spot if pretty easily if you reload a backup from 4/25 and your web page keeps spamming out the same offensive links.
I'm not knowledgeable to answer this, but I know there has to be a good "in your face, Microsoft" reason why this doesn't hit servers like Apache? They point the finger at the websites and say "UR DOIN IT RONG!" and blame them. And yet, apache users don't have to worry about this. Why? That's the argument I want to have.
"All great wisdom is contained in .signature files"
I found this article on why microsoft won't exsist for much longer. It's at http://comprog.freeforums.org/why-microsoft-will-not-exsist-for-much-longer-t31.html/
-- (this is a sig) My Computer Programming Forumhttp://www.programers.co.nr/
So... a server side exploit is "defeated" with a client side browser + extension.
In case you go to a malicious site that makes you SQL exploit a 3rd party site?
Bad language leads to bad programs. Classic example - C doesn't associate lengths with strings or arrays - and buffer overflows result. A SQL interface that requires/allows constructing strings which mix syntax and user data is asking for trouble. You can blame the programmer for not validating the input data - but unless you provide the validation tool, its still your fault - you the language designer.
certain domains from the Internet that are spreading those malwares?
I have read the news that some people have been working on finding out sites with malware on it using Google.
Ok, I *do* realize that this is really difficult and comes with crapload of legal and drama issues,
but I say we have to start from somewhere to take action on this.
And of course, some countries make it difficult (if not impossible)
to track down those malware spreaders *coughRussiacoughForExample* http://www.technewsworld.com/story/33127.html?welcome=1209421471/
and http://www.technewsworld.com/story/Researchers-Shed-Light-on-Shadowy-Russian-Botnets-60640.html/.
Now I say "Fuck those Russian bastards and their corrupted government and law enforcement agencies."
Yeah and ORM loads more data than you will need or use in comparison to a properly formed query moved to a separate db layer which has all the benefits of ORM with none of the bloat.
This is my sig. There are many like it but this one is mine.
Has anyone ever heard of a SQL injection vulnerability in a Coldfusion app? I know some smartass is going to say, "that's because nobody uses it" but that's not true. If there are a million ASP apps out there and 500,000 SQL injection vulnerabilities, then there have to be at least 100,000 coldfusion sites. Show me the 50,000 coldfusion SQL injections. Or show me 10,000, or 5,000 or even just 1.
I have some experience with coldfusion and it is my opinion that a SQL injection vulnerability is pretty difficult to create even when you intend to create one. The reason is because, unlike every other language (java, ruby, PHP, etc.) coldfusion doesn't have this idea that you take any old random string and pass it off to the ODBC. Instead, you build the query inside special tags, and the interpreter can keep an eye out for errant quotes.
a SQL injection vulnerability in coldfusion will involve a special function, preserveSingleQuotes() that you only need in very rare circumstances.
So maybe everyone should switch to a safer language, eh?
Actually, most dupes on Slashdot are a couple days apart like this one. After that they fail to be news and tend not to get reposted.
The extreme cases are actually measured in the years or hours. There's multiple cases of an article being duped 2-3 years later, especially when they're industry studies on how people use technology or occasionally about scientific discoveries. For the latter, it's often that a university announces they've done something and then publishes the results, which results in two very similar though arguably non-duplicative Slashdot articles.
On the other side, sometimes there's big news and an editor decides to get it out fast without reading the current front page. I've seen dupes within the same hour, but more likely they're 2-3 articles apart in the worst cases. This was one of the arguments for introducing the Slashdot subscription model, in fact: Subscribers have early access to upcoming articles and can tell editors that an upcoming article is a dupe. In many cases (but not all) the editor pulls the dupe before it gets pushed to the front page.
my blog
Hey, um, the same security guidelines for working with SQL code and various languages hasn't changed in over a decade guys... c'mon, this is really a pathetic takeover of the industry with people with the strongest immune systems and worst hygiene.
*puts on safety glasses*
It's not. The summary is bogus, just like when it was when it got posted last week.
Comment removed based on user account deletion
Aside from Hibernate ( which is ok ) there is LINQ (for SQL) and the ADO Entity Framework. Both are from MS and both are pretty good. The framework is in CTP and a few features are missing but I've tested the existing feature set under load and found it useful, solid, and the performance ok for not SQL Direct. LINQ is in production.
http://en.wikipedia.org/wiki/Language_integrated_query [see LINQ for SQL down the page]
http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework
I think Hibernate (for Java) is pretty good, easy to use. I found some of the problem a pain (the old compound key thing irked me). But it is suprising home many people don't like it anymore.
From what I understand from just flippering through the summary,
The attack itself injects some malicious JavaScript code into every text field in your database, the Javascript then loads an external script that can compromise a user's PC
the infection requires that a local user on that database box browses the net, and hits a malicious site?
I really wonder, if users on database-running PC are supposed to browse the net, for pr0n, or what?
Am I correct that my fictitious boxen are free from danger, if I have no local losers' accounts for surfing?
Wow, that's awful, so soon after the last issue?
Is that Linux, BSD, Sun, AIX, and whatever are just as vulnerable when it comes to dumb programmers.
The million dollar question is what platform and which web server is it easier to reinstall to get the site back up.
I think Linux and BSD have the advantage.
Enjoy,
It's just the normal noises in here.
Half a Millon Slashdot-Powered Stories Hit with Dupe Injection
Hibernate supports lazy loading in which case you can specify exactly what it has to load up front and then if you need more stuff later it will load it then.
There's problems with that approach as well, but it largely eliminates the bloat problem.
As a complete aside, I don't believe hibernate sanitizes inputs for you, so it's still possible to perform injection attacks on it
I don't have any MS SQLServers here at my site so I block all sqlserver request and my firewall gets hit with thousands of sqlserver hits everyday. I think they have bots that go out an scour the network for any sqlserver regardless they exist or not. Once they find a sqlserver then they pounce on it with a vengeance.
What you are saying is a sound argument. There are many design patterns that protect you from these kind of issues and also improve the maintainability of your application. This attack is successful because people are either creating ASP pages with DB access coded right in or are not following a design pattern that abstracts the DB access from the UI/Controller/Service layer in a way that makes SQL injection much easier to programatically test and defend against. At the end of the day they are using IIS and MS SQL Server, which shows bad judgment at the outset.
The problem is not SQL Server's support of multiple statements, but rather the way they do it. Oracle supports multiple statements, but only in a PL/SQL begin end block, which is generally speaking impossible to inject.
SQL Server on the other hand is trivially exploitable if any parameter is unchecked, due to the way statements are chained together - no block syntax required, just a semicolon and anything goes after that.
+1
but then again, he did say he was an incompetent java developer. So everything you just said is way over his head.
The query being used is exploiting features in Microsoft SQL Server, combined with a couple of external factors. Developers who have failed to check and sanitize user input, and DBAs who have not properly secured their databases. In order for your website to be owned through this attack:
- You must be running Microsoft SQL Server as your database platform
- Your web application must be vulnerable to SQL injection
- The SQL Server user that your web application authenticates as must have SELECT and UPDATE access to the sysobjects table
Notice that nowhere in that list is IIS mentioned. In addition, plenty of shops meet the first criterion above, without meeting either of the other two. Unfortunately it's all too common that web applications are configured to use the "sa" account, or some functionally-equivalent clone thereof.If your web application can query dbo.sysobjects and get anything other than "Server: Msg 229, Level 14, State 5, Line 1" in response, it's time to hire an additional DBA. If your web application allows random queries to be passed into SQL Server in the first place, it's time to hire an additional developer. In either case, make "security" a bullet-point on the job posting.
Thanks to the War on Drugs, it's easier to buy meth than it is to buy cold medicine!
I have monitored these attacks on my sites since the second week of April 2008. It should be noted that ALL of the logged attacks IP addresses resolve to CHINA, mostly in the Beijing area... Why is nobody discussing this aspect of the hack?
The problem here is that MS SQL Server supports multiple statements in the same prepare / execute block in an unsafe manner. Just insert a semicolon and off you go.
The safe way to support multiple statement execution ("query stacking") is with something like the block syntax of Oracle. Given a single unchecked entry field, the SQL Server syntax is trivially exploitable do anything the attacker wants.
$response = "Hibernate has its benefits, but you don't need to rework your whole data access layer to get protection from SQL injection, ";
$solution = "just use prepared statements " ;
$_GET = "and smack (with a blunt object) any developer that concatenates untrusted input during code review ";
echo $response + $solution + $_GET;
...it's weak idiot-proofing. Strong idiot-proofing makes it so the problem is never even encountered.
FAQs are evil.
Although I like OR-mapping frameworks, you don't need one to avoid SQL insertions. Plain old PreparedStatement in JDBC will do that job just fine also.
Everyone keeps looking at this like it is an attack on IIS and SQL Server, but the actual body of code attacked is actually JavaScript. If the client doesn't have Javascript, then nothing bad happens - with this sort of attack.
Now, there are other attacks that rely on SQL injection... and the prevention is arguably worse than the disease. These days, a lot of DBAs will say that best practice in SQL Server or any sort of database is often said to be against using SQL directly, and wrapping everything in stored procedures, but, this has huge disadvantages.
It's more expensive - you add another layer between you and your data. It all but removes ad-hoc querying off of user pages. Granted, most developers won't have it in them to build up WHERE clauses, joins and connectors into some sort of a point and shoot form, but, why are we giving that up so that we can write two hundred stored procedures instead? This sort of security costs way too much. What's the point of having SELECT if you can't use it, especially when ISAMS already give you basic CRUD out of the box.
To stop SQL injection, all you really need are two things. First is that you have a way to disable writes at the query call level, and the second is to merely scrub quotes at input from a form.
If you disable writes at the call level, one could do something like:
query( statement, false ); and the engine would not allow -any- write no matter what was in statement. At this point, the very worst that a SQL injection attack could do would be to try and get additional information from your database, but it couldn't change anything. queries for updating and input would be more complicated, for sure, but the intent here is to more safely allow dynamic sql for querying.
scrubbing quotes is just common sense.
This is my sig.
I just Googled "well-established security practices for handling database input". First 30 hits are blogrolls about this story. After three pages of results most searchers lose interest, so I won't be getting a handy checklist until some smart programmer with better bookmarks than me replies to this comment with a decent article on a website that hopefully hasn't been compromised by this attack.
/.'ers lose interest after 30 words without punctuation.
If you read all that, congratulations, most
I agree that this is not an IIS problem. IIS is just a convenient target. And it may also be the case that users of IIS are less likely to do proper data sanitation than those who can't use IIS. But I would argue that SQL is a major target of blame.
Long long ago when I first learned of SQL, it was described as a command line language which would allow people to do innovative database searches. I saw several examples of such. The lecturer was even typing them in manually. It sure looked like a really great tool, both for the database administrator, as well as for people that needed to work directly with the data in relational databases. What never came across at that point in time was that using SQL was the primary way for programs to access the database.
Later I found out the hard way that this was necessary when a program I was developing needed to get some data from the database. I almost lost my lunch. It was bad enough that user input data might be used to open a file by name. But at least reading and writing of files was done specifically by calls inside my program and didn't involve constructing strings to be parsed and interpreted somewhere. Now with the need to access something in an SQL database, I immediately saw a huge problem.
I was working with the DBA on this aspect of my project. He told me what SQL I needed to use for what I wanted access to (I didn't know any SQL at that time). I just needed to insert certain pieces of data describing what I wanted at specific places in the (rather largish) SQL commands he gave me. I could see the exposure immediately, as well as some solutions. So I just mentioned something like "I'll need to filter this so I don't have quotes in the string". He asked why. I asked "Won't a quote in the data look like the quote that ends the string?" He replied, "I guess so, but then you'd just have a syntax error". "What if someone inserts valid SQL after that which ends in a quote to start a new string?" And his reply "Why would anyone want to do that?". I just shook my head and proceeded to write code that removed everything but letters and numbers.
Had relational databases also had a means for more direct access (turns out some do) that doesn't involve any SQL, they might be safer. But what was really needed as a part of any database access library is specific code to be used to construct the SQL command line that applies all the necessary data sanitation. Even to this day I don't know if a quoted string in SQL can have a quote embedded with an escape (I never used SQL enough to need to know). If it can, then the calls to insert a quoted string in the SQL command being built should escape quotes in the C string being passed to it. If not, it should just remove them (and then you can't use quotes in a string for anything).
Maybe I should not have been so amazed at the lack of security thinking back in the 1990's when this took place. I was amazed, nevertheless. But I can see how back when they developed these interfaces, they would not have thought about all this at all. Based on all the security problems I have seen since, being amazed back then was clearly out of place. And it was a web application I was developing. Hopefully, they aren't running it anymore. But if they are, it's probably a whole lot safer than others developed by other people in that era (and, unfortunately, even those developed today).
Yes, programmers of the web applications are significantly to blame. But SQL should have included the tools to make constructing safe SQL from unsafe tainted data work in a safe way ... and made those tools the standard way to do things (not unsafe tools like sprintf from the C library, or similar from languages used today).
In summary, my blame (mostly) points at SQL itself.
now we need to go OSS in diesel cars
... who failed follow well-established security practices...
Yeah, like letting OS-es never meant to be networked out on the Internet
Microsoft SQL Server is particularly vulnerable to SQL injection in a way that most other databases aren't. The problem is multiple statement execution just by inserting semicolons.
Catalog access isn't much of a vulnerability if an attacker cannot trivially execute SQL ad lib. with a single unchecked parameter.
That is not correct. MS SQL Server is vulnerable in a way that no other database that I am aware of (Sybase perhaps) due to the way it constructs compound statements.
Oracle is not vulnerable to this type of attack, nor is DB2, nor PostgreSQL. Some databases, like MySQL, are apparently only vulnerable when using a Microsoft ADO driver - same design mistake: support for compound statements without requiring block structure (BEGIN / END) allows trivial injection of arbitrary SQL.
Twenty or so years ago, using dynamically generated SQL was expensive, slow, and hard to program. The vast majority of SQL applications were written with SQL statically embedded in C, FORTRAN, or COBOL dialects that had to be translated to the base language using a precompiler.
Parameters were bound by name to host language variables, and the precompiler handled the mapping to the underlying database library. Much more secure than dynamic SQL without bound parameters.
Of course as computers got faster, the penalty for not binding parameters was reduced. Application language developers got lazy and added SQL APIs without any way to bind parameters at all. ColdFusion was this way for years, for example. The first time I saw it I was shocked - not so much for security reasons, as for the low efficiency the lack of such support implied.
In short - barring a few semantically impaired languages - it has always been possible (and once was the far and away predominant practice) to bind typed parameters to SQL statements and avoid potential injection vulnerabilities completely.
Of course, in a script you (obviously) can put multiple statements, but a script is not what the webapp (written in ASP or PHP) uses when communicating with the DB back end.
So, if you have an ASP front-end with an Oracle or Mysql back end, you are not vulnerable to this kind of SQL injection, but you might be vulnerable to other kinds, which don't involve multiple statement execution. However most generic cookbooks or exploits do need the multiple statement vulnerability.
How about using some stored procedures and character filtering? I really fail to see how this problem has anything to do with Microsoft. If your code sucks, SQL injection can be done on pretty much any platform that uses a database.
Not doubting you, but I'm pretty sure if I run something like
Then it will execute with no problems. Maybe I'm just not savvy enough with MySQL to understand what you're saying.
I do know that, for instance, this specific injection attack uses cursoring...sure, in MySQL cursoring is handled differently, that doesn't make Microsoft responsible for this "vulnerability." It's still the fault of the ASP developer for not sanitizing his inputs.
Are not the problem. That is a feature and one that is used very often as ADO also supports multiple recordsets.
.NET or classic. If people want to use their crud generators and whatnot fine, but please abstract your database code back into the database. It's lazy not to do so.
The solution is to use these tools properly. For years SP's were the norm for people doing database development. Then the younger generation of coders really took to crud generators and very often I see people totally arguing against SP's. Mostly I chalk this up to lack of experience. I really don't care which one is faster, having all my code that directly references database object at the database level is just a "no duh" right way approch.
SP's with parameters (also supported by ADO) is the way to go. Either
If the coder of the site doesn't thoroughly filter their data passed to the query, they deserve to be h4x0red.
Code is vulnerable because app tries to create a whole SQL command string with parameters in it dynamically and passes it to SQL driver to execute. Not only is it slow but you also easily forget to escape the parameters. It is better to use the bound parameters method instead, having static SQL command string (with placeholders for parameters) and bound parameters passed along it. In that case, the SQL is static, does not contain any externally provided data and can be better optimized by the server, and you avoid any escaping issues and cost alltogether. For example, in JDBC you would use PreparedStatement. Of course, some databases/SQL APIs do not support it ;(
Hibernate guards against SQL Injection by using PreparedStatements with bind variables.
"You cannot simultaneously prevent and prepare for war." -- Albert Einstein
Sorry, I think I missed something. What exactly does Firefox and NoScript have to do with this, again?
A community-oriented lyrics site
I have to say this is the most succinct explanation of why SQL Server is specifically vulnerable to the attack. It's certainly something for Microsoft to look at the next time they look into modifying T-SQL.
I do not, however, think this rises to the level of actually being able to blame Microsoft for the attack. The fault there lies 100% on the shoulders of programmers who did not use the tools available to them to eliminate SQL injection.
The structure of T-SQL did allow the hackers to add the javascript to every text field in the database, yes. But the fact that they were able to allow javascript to *any* text field is entirely the fault of the site programmers.
"Times have not become more violent. They have just become more televised."
-Marilyn Manson
Ignoring corporate spin-doctoring there seems to be plenty of blame to go around.
College-Pages.com - Online Colleges, Degrees, and Programs